Does pushing an entity to a it’s parent collection causes the collection to be loaded?
e.g.:
Parent.childs << a_child
Is the parent.childs “array” now loaded with ALL the childs or just “a_child” ? i.e. will a SQL “select * from childs where parent_id = ?” statement will be executed before adding to the collection?
EDIT:
http://apidock.com/rails/v3.2.3/ActiveRecord/Associations/CollectionAssociation/concat_records seems to call “add_target” BEFORE calling “insert_record” which adds the entity to the @target array…
No (thank god)!
Parent.childsis a Proxy and ‘<<‘ will just trigger the creation/update ofa_childMore info on How do rails association methods work?
Also in the rails comments of associations/collection_associations.rb
A quick check on my console confirmed there the children aren’t loaded.
=> only parent and child where loaded….