Rails 一个关于 Mongoid 中一个类关联到自身的问题

yzhrain · June 18, 2012 · Last by reducm replied at June 04, 2013 · 4087 hits

比如一个类要自关联到自身,在 ActiveRecord 中一般是这样写的:

class Comment
  belongs_to :parent,:class_name => 'Comment'
  has_many :childen,:class_name => 'Comment',:foreign_key => 'parent_id'
end

我看了半天 Mongoid 的文档,只有几个例子,我不知道它是否完全兼容 ActiveRecord 的用法。

You need to Sign in before reply, if you don't have an account, please Sign up first.