加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 23:28:44 所属栏目:百科 来源:网络整理
导读:我是mongoid的新手.我在Ryan Bate的屏幕演员#238的帮助下开始用 rubyonrails做mongoid. 我在mongoid官方网站的“参考”部分中找到了描述has_many的部分. 任何人都可以帮我解释一下has_many和references_many之间的区别是什么以及哪个版本的mongoid支持它们.
我是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:如果你需要:)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读