> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to