IAmNan wrote: > I've put the relevant code here: http://pastie.org/1100297 > > So you know what's happening, the farmer creates a Production, which > creates one or more Supplies, which may create one or more Exchanges > if there are any Demands that match the Supply. > > The Exchange is supposed to decrement the "available" variable in both > the Supply and Demand models (the "quantity" variable doesn't change). > > On exchange.rb#18 where the debugger stops, the values of > demand.available and supply.available have been correctly decremented. > After I let the code continue, they are back to their original values.
Maybe what you're trying to do is a bit too complex for use in after_save. Maybe it should instead be done using a transaction. I'm not 100% sure, but worth a try: http://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

