mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 03:37:56 +01:00
25 lines
455 B
Ruby
25 lines
455 B
Ruby
class CommentPolicy < ApplicationPolicy
|
|
def permitted_attributes_for_create
|
|
if user.moderator?
|
|
[:body, :parent_id, :is_post_update]
|
|
else
|
|
[:body, :parent_id]
|
|
end
|
|
end
|
|
|
|
def permitted_attributes_for_update
|
|
if user.moderator?
|
|
[:body, :is_post_update]
|
|
else
|
|
[:body]
|
|
end
|
|
end
|
|
|
|
def update?
|
|
user == record.user or user.moderator?
|
|
end
|
|
|
|
def destroy?
|
|
user == record.user or user.moderator?
|
|
end
|
|
end |