RE: Setting a default order for a model?


#1

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)
end
end

Then just do: @rooms = Room.find_ordered

Regards,

Dan