← Back to Upcase

Sugestions for multiple roles for each user in a application


(Renan Gurgel) #1

Hi, in my current application I am using CanCan for authorization. My problem is that I store all possible permission in a ROLES array like this:

ROLES = %w[users#read users#edit users#create users#destroy
             imports#read imports#edit imports#create imports#destroy... etc]

So, every user has your onw roles_mask like Ryan Beats explain how is calculated here: https://github.com/ryanb/cancan/wiki/Role-Based-Authorization.

But the application have been growing and the current ROLES array have 64 options and the current roles_mask value are too big and can´t be stored in database.

I´m sure that have a better strategy to handle with this, but I didn´t found yet. I have checked other gems like pundit, but the problem is the strategy to handle with this multiples roles for users.

Anyone could help? Thanks.