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?
|
2023-01-16 13:49:45 +01:00
|
|
|
owner?
|
|
|
|
end
|
|
|
|
def owner?
|
|
|
|
member == record.member
|
2023-01-16 00:11:05 +01:00
|
|
|
end
|
|
|
|
alias :update? :edit?
|
|
|
|
alias :destroy? :edit?
|
|
|
|
|
|
|
|
end
|