开发者

Mongoid embeds_many with default order

How can I set default order to my embeded objects, like:

开发者_如何学C
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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜