I need to create a row in both tickets and users table… I just need to know how to process in case the transaction fails.
@ticket.transaction do
@ticket.save!
@user.save!
end
#if (transaction succeeded)
#.....
#else (transaction failed)
#......
#end
On a side note I’d just like to thank everyone who participates at stack overflow for helping a designer learn more programming… I appreciate the time you guys take out of your day to answer n00b questions like this 🙂
If you are using the save! method with a bang (exclamation point), the application will throw an exception when the save fails. You would then have to catch the exception to handle the failure.