Improve performance for study_group_policy.rb

This commit is contained in:
Sebastian Serth
2021-01-23 00:25:54 +01:00
parent 008d29fcd0
commit 3b58cadbeb

View File

@ -4,7 +4,7 @@ class StudyGroupPolicy < AdminOnlyPolicy
end end
[:show?, :destroy?, :edit?, :update?, :stream_la?].each do |action| [:show?, :destroy?, :edit?, :update?, :stream_la?].each do |action|
define_method(action) { admin? || @user.teacher? && @record.present? && @record.users.include?(@user) } define_method(action) { admin? || @user.teacher? && @record.present? && @user.study_groups.exists?(@record.id) }
end end
class Scope < Scope class Scope < Scope