Difference between reference_many and has_many in mongoid

I am new to mangooid. I'm starting to make a mangoid with rubyonrails using screen casting # 238 by Ryan Bath.

I found in the "Link" section of the official mongoid website describing has_many.

Can someone help me explain what is the difference between has_many and reference_many and which version of mongoid supports them.

Thank you very much.

+6
source share
1 answer

From mongoid doc you can read this:

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

Relational associations will no longer autosave when a parent relationship is created. Previously, a new document was saved, reference_many or reference_one would load the relationship on it first stored. To return this functionality, autosave: for the macro, the true option must be provided (this only applies to reference_many and reference_one):

So now I think there are no differences, and you can use has_many for free with autosave: true parameters autosave: true if you need to :)

+9
source

Source: https://habr.com/ru/post/893747/


All Articles