P124 create action code doesn't work as described
Reported by Chris Bailey | March 31st, 2008 @ 06:07 AM | in Second Edition
I believe this to be a bug in the book, but if it's a bug in Rails, or similar, that'd be good to know. I've tested this against Rails 2.0.2.
According to the book, it says that this create action's code will create an auction object, and then build it's associated item, then do an @auction.save, which if it fails, won't create the item, etc. The problem is, that if the item itself fails validation, the @auction.save still succeeds (but now won't have the item).
From what I can tell, a) this sucks, as it'd be great if it really worked as the book implies, but b) it seems what you'd have to do instead is instead of "if @auction.save", do:
if @item.valid? && @auction.save
Comments and changes to this ticket
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
