ruby-on-rails – mongoid中references_many和has_many之间的差异

我是mongoid的新手.我在Ryan Bate的屏幕演员#238的帮助下开始用 rubyonrails做mongoid.

我在mongoid官方网站的“参考”部分中找到了描述has_many的部分.

任何人都可以帮我解释一下has_many和references_many之间的区别是什么以及哪个版本的mongoid支持它们.

非常感谢你.

解决方法

从mongoid doc你可以读到:

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

Relational associations no longer autosave when the parent relation is
created. PrevIoUsly a save on a new document which had a
references_many or references_one association loaded would save the
relations on it’s first save. In order to get this functionality back,
an autosave: true option must be provided to the macro (This only
applies to references_many and references_one):

所以现在我认为没有差异,你可以免费填写使用has_many和选项autosave:如果你需要:)

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...