How do I setup the roles for CanCan, and how do I assign those roles to users? I’d like for now at least to have a dropdown menu upon registration for a user to select their role. I’m not quite sure with all of the documentation I keep seeming to miss this, but any help is greatly appreciated!
Share
I figured this out for the most part.
For instance:
This is basically “setting up” the admin role. For some reason I thought you would have to initialize that role elsewhere as well.
To assign the roles, following most tutorials I’ve seen, you need to go into the rails console and use something similar to:
The first line finds the user, and the second adds the role. The third is used to check if the user is assigned to that role. There are also ways to add this upon registration, and a few others as well. I’ll try to list them here as I run across them, but hopefully this clears up any confusion for someone in the future. 🙂