leonb
#1
Hi all,
I have a model user.
A user has_many :roles
Roles: admin, super admin, user
This specific user has the admin role. But for a view I want to list all
roles.
Is it possible to do something like:
“user.roles_all”? and get all the associated roles AND the ones not
currently associated with the user?
So I can create some checkboxes with the ones checked that are
associated.
I hope I’ve explained it right.
Thanks in advance!
leonb
#2
Role.find(:all)
Leon B. wrote:
“user.roles_all”? and get all the associated roles AND the ones not
currently associated with the user?
So I can create some checkboxes with the ones checked that are
associated.
I hope I’ve explained it right.
Thanks in advance!
–
http://www.5valleys.com/
http://www.workingwithrails.com/person/8078
leonb
#3
do this in the controller
@roles = Role.find :all
and in the view use the @roles variable
On Feb 1, 12:13 am, Leon B. [email protected]
leonb
#4
ajaxrussia wrote:
do this in the controller
@roles = Role.find :all
and in the view use the @roles variable
On Feb 1, 12:13 am, Leon B. [email protected]
And how would I now then which roles are associated with the user? That
line only gets all the roles.