small medium large xlarge

19 Sep 2008, 09:38
Jakub Żurkowski (2 posts)

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.

19 Sep 2008, 16:03
Sam Ruby (633 posts)

implicit save. I just verified this using the debugger. I don’t see this mentioned in the “Rails documentation”:

20 Sep 2008, 17:27
Jakub Żurkowski (2 posts)

hmm… that’s strange - if « saves the relation into database, then why is this used (p.449): * @article.comments « comment if flash[:note] = “Thank you for your valuable comment” end*

instead of

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 to be always true, but I rethought it and now I guess that it would also be nil)

You must be logged in to comment