hubfeenix.fi/app/policies/edit_own_policy.rb
2023-01-16 22:02:33 +02:00

15 lines
268 B
Ruby

# allows to edit/detroy own data
# which can be viewed by anyone
class EditOwnPolicy < ApplicationPolicy
def edit?
return true if member.admin?
owner?
end
def owner?
member == record.member
end
alias :update? :edit?
alias :destroy? :edit?
end