Is it possible to set up a Rails application such that all controller actions are automatically wrapped with a transaction, that gets automatically rolled back in case of unrescued exceptions?

I'm working on a Rails 3 application, currently for a fairly tricky action that makes numerous database changes. And I've been getting it wrong, lots of times! After a while I realised my code wasn't working because I'd ended up with inconsistent data in the database.

I can easily enough wrap this with a transaction (it is a clear instance where one is needed!). However it got me thinking that, at least in development, it would be useful to apply this idea across every controller action.

Assuming it is possible, is there any downside to this?

Edit
Report