Hello All,

Is there any gem for Authorising Permission based on users ?
Like Cancan is used for role based authorisation.


You can set permissions for every role using CanCan.

There can be multiple permissions for a single role. How to handle that?


Iam using the rolify gem in my project and found it to be very useful check this out


Yes, this makes some sense.
But this is helpful, when you have only one user per role.

Suppose you are an admin. & under Admin there are 5 sub-admins. All sub-admins have different permissions, but role is still the Admin.
Admin need to assign different different permissions to those 5 sub-admins.
I guess this can’t be achieved through CanCan because this is a Role-based authorisation.

Can you explain with an example so that I can better solve your problem?

The purpose you want to achieve includes a huge number of if conditions. I can give an example but better is that you provide some scenario.

Thanks for reply.

So here is the requirement :-

I have an Admin (Admin is a role). & under Admin there are 5 users. All users(same role as Admin) have different permissions.
Those users can be differentiated by their permissions to perform tasks.
Admin need to assign different different permissions to those 5 users.
Here implementation of giving permissions to the role Admin is important. How to achieve this?
An User has has_many relationship with Permission.

In CanCan, we can only define role, but not permissions.

You can have 5 different roles with different permissions you want to assign each of the admin.

Well, as per the requirement, the role is one- i.e. Admin. But permissions need to be different for admin users.

It doesn’t make sense that a role has different permissions. You can create more roles and assign them different permissions. The purpose you are trying to achieve will always require different roles.