hubfeenix.fi/app/policies/edit_own_policy.rb

15 lines
265 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?
return true 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