Answer 2 out of 5
 
4 helpful answers
A:

What I'm trying to do is to make sure certain models are only ever saved inside a transaction.

So I wat to write a macro method such that I can do:

class Foo < ActiveRecrod::Base

  require_transaction

 end

And it will throw an exception if in before_save it detects that there's no transaction going. i.e.

@foo.save! # should fail

AnyOtherModelOrFoo.transaction do

  @foo.save! # should work

end

 

 Next stage will be detecting if the model is locked. i.e. if it was selected with :lock => true. But this is step 2 :-)

 

 
Comment About This Answer (or add your own answer)

Feed - Subscribe to changes to this Q&A Blog
ADVERTISEMENT
ADVERTISEMENT
AOL Autos Q&A is powered by Yedda an AOL Company
Copyright © 2006-2009, Yedda Inc. and respective copyright owners