Where to put the transaction?

Hi, I'm rewriting some really old code these days and I'm trying to adhere to the "fat model, skinny controller" approach.

I'm wondering how much to actually stuff into the model, and if there's some rule of thumb. For example, I could do this in a controller:

def controller_action   MyModel.transaction do     instance.do_stuff     instance.associated_thing.other_stuff     instance.save!   end end

Or, I could put it all on the model instance:

def do_stuff   MyModel.transaction do     some_methods_here     associated_thing.other_stuff     save!   end end

Any tips on what's preferable and when/why?

Thanks.

Hello,

This is just a "me too" ... I am just now comfortable enough with rails to be able to accomplish a task both of those ways, and I have a tough time figuring out when I should choose on or the other. The Railscasts from http://railscasts.com/ are quite helpful, that's how I have been figuring it out.

Dustin