How to Sort by a column from another table

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, :order => sort)

@users = User.find(:all, :include => :division, :order =>

(assuming Division has a ‘name’ field)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs