I have a rails app with articles and author model. If I have an author and a post and want to indicate that the author should be the owner of the article, or that the articl
There is not difference between the 3 following:
my_article.author_id = author_one.id
my_article.save
# same as
my_article.author = author_one
my_article.save
# same as
author_one.articles << my_article
To set the owner of a particular post, the most common and readable way would be:
post.author = author
post.save
OR shorter version:
post.update_attributes(author_id: author.id) # call an implicit save