【发布时间】:2013-04-09 07:31:09
【问题描述】:
我有这样的代码:
user.posts.size #=> 5 already saved
user.posts.new(title:"foo")
user.posts.new(title:"bar")
user.posts.sort_by! { |e| e.title } #=> sort correclty
user.posts #=> sorted but with the saved on the top, the new one at the bottom
我使用field_for 的排序,但显然它仍未排序。
使用:Rails 3.2.11 和 Mongoid 3.0.23
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 mongoid mongoid3