How can I set default order to my embeded objects, like:
开发者_如何学Cclass Post
embeds_many :comments, :order => "author"
accepts_nested_attributes_for
end
Now I handle it with passing order straight:
f.fields_for :comments, @post.comments.asc(:author) do |comment|
...
end
In mongoid 3.1.2 you can do something like this:
embeds_many :favorites, order: :title.desc
It also works with :title.asc
精彩评论