This project is archived and is in readonly mode.

#256 ✓stale

Model objects are falsely marked as not-new after transaction rollback

Reported by pdietrich | May 26th, 2008 @ 05:26 PM

Consider the following code from a controller action:

  @auction.transaction do! = @auction!
    flash[:notice] = 'Auction was successfully created.'
  render :action => "new"

If no validations fail on @auction ActiveRecord considers it saved even if the transaction cannot be finished successfully (e.g. when raises an exception). Hence @auction.new_record? will return false although the record is not saved in the DB.

This leads a problem in the view:


will generate a put (to controller action 'update') instead of a post (to controller action 'create').

I think the right way to fix this is to remember which model objects have been saved in a transaction and to revert their state after rollback. Any suggestions how this could be done the best?

Comments and changes to this ticket

Create your profile

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

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>