R
R
rda_19022014-03-05 22:43:06
Ruby on Rails
rda_1902, 2014-03-05 22:43:06

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 @personand 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

5 answer(s)
I
Ivan Kryak, 2014-03-06
@rda_1902

cancan

R
rda_1902, 2014-03-06
@rda_1902

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)

R
rda_1902, 2014-03-10
@rda_1902

I solved the issue through cancan, figured out the gem in more detail. At the first study, I did not fully understand the gem (((

A
Alexey, 2014-03-12
@fuCtor

You can also consider cancan in conjunction with rolify

D
dexdev, 2014-03-24
@AdilA

well then the answer to the studio, how did you implement it? preferably with code and examples! or blog post

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question