新手问题 请问 mongoid has_many 带上 scope 要怎么写

dxwts · December 12, 2014 · 1601 hits

sqlite 好像可以按下面的方法写,但我用了 mongoid 这样写却不行。

has_many :comments, -> { order "posted_on" }
has_many :comments, -> { includes :author }
has_many :people, -> { where("deleted = 0").order("name") }, class_name: "Person"
has_many :tracks, -> { order "position" }, dependent: :destroy
has_many :reports, -> { readonly }
No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.