Saturday, December 08, 2007

rails order include




I had a model that linked to another model in Rails, and I wanted to order the first model by a field in the second model. Here's what I came up with:


has_many :set_bin_items, :include => :produce_item, :order => 'produce_items.fruit DESC, produce_items.fruit_bin_only'