Rails new vs build
@article = Article.new
Creates a new instance of a Model.
@comment = @article.comments.build
Just like the new method, but by assocation proxies (not for Models). It automatically sets the foreign_key.
The other thing is that when you are doing a “has_one” the build looks like this:
@comment = @article.build_comment
21 Notes/ Hide
-
elliottheis posted this
