【发布时间】:2010-01-05 05:15:33
【问题描述】:
我有一个包含嵌套对象的表单,如下所述:
http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes
它工作正常,但我需要按其“名称”属性对表单中的嵌套对象进行排序,以便它们按字母顺序列出。
有什么想法吗?
【问题讨论】:
-
源不再可用
标签: ruby-on-rails
我有一个包含嵌套对象的表单,如下所述:
http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes
它工作正常,但我需要按其“名称”属性对表单中的嵌套对象进行排序,以便它们按字母顺序列出。
有什么想法吗?
【问题讨论】:
标签: ruby-on-rails
为关联设置默认排序,例如:
has_many :children, :order => "name"
【讨论】:
我最终只是在嵌套模型的默认范围内设置了排序顺序:
default_scope :order => 'name'
【讨论】: