hubfeenix.fi/app/policies/edit_own_policy.rb

15 lines
268 B
Ruby
Raw Normal View History

2023-01-16 00:11:05 +01:00
# allows to edit/detroy own data
# which can be viewed by anyone
class EditOwnPolicy < ApplicationPolicy
def edit?
2023-01-16 21:02:33 +01:00
return true if member.admin?
owner?
end
def owner?
member == record.member
2023-01-16 00:11:05 +01:00
end
alias :update? :edit?
alias :destroy? :edit?
end