Active Record’s << or push or concat method

Active Record’s << or push or concat method – Introduction

You have used it over and over again but yet there are some gotchas you have to keep in mind when you are using ActiveRecord’s << method of a has_may association.

I was always wondering how ActiveRecord handles the situations where you add a new object in a collection (via of course the << method) and the owner is also new, does it saves the object before adding it to the collection or waits for the owner to get saved and then saves the unsaved objects to the DB? This is one of the questions that are gonna get answered in the following post.

Continue reading