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

前端之家收集整理的这篇文章主要介绍了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:如果你需要:)

猜你在找的Ruby相关文章