Answer the question
In order to leave comments, you need to log in
How to share access to rails_admin records?
There is a model with tasks. Please tell me how to allow editing only your own tasks, and prohibit others. There are also two models: admin and user.
Answer the question
In order to leave comments, you need to log in
I used the pundit
gem for a similar task .
And here is such a Policy Object:
class CommentPolicy
attr_reader :user, :comment
def initialize(user, comment)
@user = user
@comment = comment
end
def update?
owner?
end
def destroy?
owner?
end
private
def owner?
comment.user == user
end
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question