1
votes

I've got a form with nested objects as described here:

http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes

It's working fine, but I need to sort the nested objects in the form by their "name" attribute so they are listed in alphabetical order.

Any ideas?

2
source is not available anymore - bert bruynooghe

2 Answers

5
votes

Set a default ordering for the association, for example:

has_many :children, :order => "name"
2
votes

I ended up just setting the sort order on the default scope of the nested model:

default_scope :order => 'name'