Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

the diffence between references_many and has_many in mongoid

I am new to mongoid. i start doing mongoid with rubyonrails with help of screen cast #238 of Ryan bate.

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

Can anyone help me to explain what is the difference between has_many and references_many and which version of mongoid support them.

Thanks you very much.

like image 1000
channa ly Avatar asked Jul 28 '11 06:07

channa ly


1 Answers

From mongoid doc you can read this :

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):

So now I think there is no differences and you can fill free to use has_many with options autosave: true if you need to :)

like image 150
Pierre-Louis Gottfrois Avatar answered Oct 30 '22 17:10

Pierre-Louis Gottfrois