Has_many: get all objects, not only associated

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!

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

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]

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.