How can I set default order to my embeded objects, like:
class 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With