I have a function that displays all depts and related info from other
tables in my Department model, such as:

  def dept_and_hospital
    "#{name} (#{floor.building.hospital.name})"
  end

... which is used in my view, like:

  <p>
    <%= f.label :department_id %><br />
    <%= collection_select(:device, :department_id, Department.all(),
:id, :dept_and_hospital, :prompt => 'Select Department') %>
  </p>

How do I sort the display names by the hospital name (which is a few
"tables away" in the db schema), and then by the department name.

The relationship in the db is as follows:
department-->floor-->building--> hospital.

THANKS!

-- 
Posted via http://www.ruby-forum.com/.

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

Reply via email to