use member settings, remove show, tighter pundit
This commit is contained in:
11
app/policies/admin_policy.rb
Normal file
11
app/policies/admin_policy.rb
Normal file
@ -0,0 +1,11 @@
|
||||
# allows to edit/detroy own data
|
||||
# which can be viewed by anyone
|
||||
class AdminPolicy < ApplicationPolicy
|
||||
def edit?
|
||||
member.admin?
|
||||
end
|
||||
alias :update? :edit?
|
||||
alias :show? :edit?
|
||||
alias :destroy? :edit?
|
||||
|
||||
end
|
@ -1,4 +1,13 @@
|
||||
class MemberPolicy < EditOwnPolicy
|
||||
class MemberPolicy < AdminPolicy
|
||||
|
||||
def update?
|
||||
return true if member.admin?
|
||||
owner?
|
||||
end
|
||||
|
||||
def owner?
|
||||
member == record.member
|
||||
end
|
||||
|
||||
class Scope < Scope
|
||||
end
|
||||
|
Reference in New Issue
Block a user