Forum: Ruby on Rails RE: Setting a default order for a model?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Berger, Daniel (Guest)
on 2006-01-31 19:13
(Received via mailing list)
> Thanks,
> Jason

I'd recommend defining a custom method:

class Room < ActiveRecord::Base
   def self.find_ordered(first='name', second='room_number')
      self.find(:all, :order => "buildings.#{first}, #{second}",
:include => :building)

Then just do: @rooms = Room.find_ordered


This topic is locked and can not be replied to.