> I need to create a list of users sorted by division. How do I sort
> User
> table by Division name? I can only get it to sorted by division_id.
>
> Part of my code is shown below:
>
> sort = case params[''sort'']
> when "id" then "id ASC"
> when "email" then "email ASC"
> when "division_id" then "division_id ASC"
>
>
> @users = User.find(:all, :order => sort)
@users = User.find(:all, :include => :division, :order =>
''divisions.name'')
(assuming Division has a ''name'' field)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---