I thought that might be the case. I’d go with the rescue exception approach then. The API [http://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html
] seems to suggest that the transaction will raise an exception that you can rescue. You big hero, you. If you’re trying to determine which of the object.saves failed you could always do something like
begin
saved =
Merchant.transaction do |t|
@merchant.save!
saved << :merchant
@other_thing.save!
saved << :other_thing
end
Make sure to redirect before the end of the error handling
redirect_to :action => :whatever
rescue
Stay here, render the error, let the user correct and resubmit the form
Check the “saved” variable to see which models got saved correctly.