Hi,
I am trying to implement Declarative Authorization in my rails 4 app. I think my questions are possibly too simple to have been addressed in the documentation.
I have a user model (which has many roles) and a role model (which belongs to user).
The role model has a single attribute (string: name).
The user model includes the following method:
def role_symbols
roles.map do |role|
role.name.underscore.to_sym
end
The role permissions are defined in authorization_rules.rb.
My questions are:
1. Should I have more attributes in my role model? I specifically wondered whether it was sensible to have boolean attributes for each role defined in the authorization_rules.rb file so that I can then mark the relevant role as true when a user is created.
2. What is the best way to go about allocating roles to users? If the boolean logic I describe above is not the best way, I would very much welcome tips on how to approach this.
Many thanks,
Melanie