I assume that you mean author_one.articles << my_article , not just author_one << my_article
One of the differences between them is that
author_one.articles << my_article
Save changes to the database immediately. that is, it will either create an entry for my_article if it has not been saved before, or update an existing entry to have author_id = author_one.id
then
my_article.author = author_one
or
my_article.author_id = author_one.id
will not persist until you execute my_article.save
mikej
source share