我有以下设置:
class Evaluation
include Mongoid::Document
default_scope -> { order("_id ASC") }
has_many :children, order: "position ASC"
end
class Child
include Mongoid::Document
default_scope -> { order("_id ASC") }
field position, type: Integer, default: 0
end
当我致电evaluation.children
时,position
订单不受尊重。我该怎么办?
答案 0 :(得分:2)
这对我有用:
has_many :children, order: :position.asc