Files
codeocean/app/policies/comment_policy.rb
2016-04-27 17:16:23 +02:00

23 lines
309 B
Ruby

class CommentPolicy < ApplicationPolicy
def author?
@user == @record.author
end
private :author?
def create?
everyone
end
[:new?, :show?, :destroy?].each do |action|
define_method(action) { admin? || author? }
end
def edit?
admin?
end
def index?
everyone
end
end