Improve performance for study_group_policy.rb
This commit is contained in:
@ -4,7 +4,7 @@ class StudyGroupPolicy < AdminOnlyPolicy
|
||||
end
|
||||
|
||||
[: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
|
||||
|
||||
class Scope < Scope
|
||||
|
Reference in New Issue
Block a user