In the Rails 3 app that I'm building to help me learn Ruby on (and) Rails, I'm a bit confused by the "roles/roles_users/users" tables.
I have Devise and CanCan and I want to "access" these roles.
Right now, I have three roles:
admin
staff
client
In the database, I have these tables (and a few others):
roles (table)
id => 1 || name => admin
id => 2 || name => staff
id => 3 || name => client
roles_users(table)
role_id => 1 || user_id => 1
role_id => 2 || user_id => 2
role_id => 3 || user_id => 3
users(table)
user1
user2
user3
So right now I have three users. User #1 is "admin", User #2 is "staff", and User #3 is "client."
In "views/admin/users/show.html.erb", I would like to display each user's "role" and then also allow the admin to change it. Once I am able to display the role, I think I can set it up so that admin can change it.
The thing is...I'm a bit confused as to which variable/name I can use to show each user's role. I can easily access things like user.first_name or user.address, but I'm unsure how I can access something like user.role (which doesn't work).
Any suggestions?
Cheers!
Sam