in restful2/app/controllers/comments_controller.rb listed in pages 434/5 in action “create” (and “update” also) we don’t save the parent after doing « operation (or update_attributes in “update”). Probably it’s just a typo, because page 341 states that you need to save the parent of has_many relationship explicitly after that « operation in order to write it into database. Please dispel my doubts.
implicit save. I just verified this using the debugger. I don’t see this mentioned in the “Rails documentation”:http://api.rubyonrails.com/classes/ActiveRecord/Associations/ClassMethods.html
hmm… that’s strange - if « saves the relation into database, then why is this used (p.449): * @article.comments « comment if @article.save flash[:note] = “Thank you for your valuable comment” end*
if(@article.comments « comment) end
which I see in my very first example from page 435?
this code seems to save article twice (or at least once a new comment and once an @article) or not at all.
(firstly I thought it makes second @article.save to be always true, but I rethought it and now I guess that it would also be nil)