Answer the question
In order to leave comments, you need to log in
Is there a Gem to assign and check permissions on any instance of an ActiveRecord object?
When creating an object, for example, person, the user can set the rights to this object, for example:
-access for everyone
-only the owner
-select users who are granted access to the object.
How to implement it is clear. But since the task is trivial, there may already be a gem with similar implementations of permissions. I have looked at all the gems at www.ruby-toolbox.com but none of them fit.
I need such an algorithm user1.can :read @person
and save it to the database, and then when I user1.can? :read @person
pull out the rights from the database and check access. Is there something similar?
Answer the question
In order to leave comments, you need to log in
I represent the table like this
id
objectable_type
objectable_id
action
user_id integer
everyone boolean
only_owner boolean
Well, can methods, can? add to the User model + provide methods for deleting rights and assigning several rights to one object for one user + cover with tests even that day of work) Started
a topic, because people write gems to add created_by and delete_by to the model, like a trifle 10 minutes, but still saves time)
I solved the issue through cancan, figured out the gem in more detail. At the first study, I did not fully understand the gem (((
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question