#121 ✓resolved
Chris Bailey

P124 create action code doesn't work as described

Reported by Chris Bailey | March 31st, 2008 @ 02:07 AM | in The Rails 3 Way

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 Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Shared Ticket Bins

People watching this ticket