【问题标题】:the diffence between references_many and has_many in mongoidmongoid中references_many和has_many的区别
【发布时间】:2011-07-28 06:14:59
【问题描述】:

我是 mongoid 的新手。在 Ryan bate 的屏幕演员 #238 的帮助下,我开始使用 ruby​​onrails 做 mongoid。

我在mongoid官网的“参考”部分找到了关于has_many的描述。

谁能帮我解释一下 has_many 和 references_many 之间的区别以及哪个版本的 mongoid 支持它们。

非常感谢。

【问题讨论】:

  • 都是别名,没有区别。

标签: ruby-on-rails reference mongoid


【解决方案1】:

您可以从 mongoid 文档中阅读:

http://mongoid.org/docs/upgrading.html

当父关系为 创建的。以前保存在一个新文档上,该文档具有 加载的references_many 或references_one 关联将保存 关系就它的第一次保存。为了恢复此功能, 必须为宏提供 autosave: true 选项(仅此 适用于references_many 和references_one):

所以现在我认为没有区别,如果需要,您可以免费使用 has_many 和选项 autosave: true :)

【讨论】:

    猜你喜欢
    • 2012-06-07
    • 2011-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-25
    相关资源
    最近更新 更多