[Rails-core] Re: Is there an "before_commit" hook somewhere in Rails? after_save does not help (example code attached)

2009-01-24 Thread Greg Hauptmann
Hi Matt/all, Actually from what I can see Rails does not hold off on trigger it's "after_save" callbacks until just before commit in the case they are wrapped in a specific transaction (unfortunately). So there's still no "before_commit" equivalent yet anyone has identified. Let me know if I'm w

[Rails-core] Re: Help with how is Template handler works for rails 2.2.2

2009-01-24 Thread Michael Koziarski
> MY problem is: the final result will be a generated file on the > filesystem, and i couldn't figure how to throw send_file in the mix. i > looked at prawnto, rjs, builder and fleximage plugins. but all do not > generate results on the filesystem (aka do not use send_file). Josh is the guy who k

[Rails-core] Re: Is there an "before_commit" hook somewhere in Rails? after_save does not help (example code attached)

2009-01-24 Thread Matt Jones
There's no explicit hook, but you can pretty much do what you've described using transactions. If you're updating the chapters in a single controller action, you can use a transaction block (see http://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html) to wrap all the

[Rails-core] Re: Is there an "before_commit" hook somewhere in Rails? after_save does not help (example code attached)

2009-01-24 Thread Greg Hauptmann
Hi Mike, all Understood. To help align my fictitious example to the cross-model validation question I've asked consider that: (a) the book value is fixed [e.g. perhaps think of this as a bank account transaction amount, being allocated out to different tax categories & then the user wants to adju

[Rails-core] Re: Is there an "before_commit" hook somewhere in Rails? after_save does not help (example code attached)

2009-01-24 Thread Mike Mangino
Personally, I normally solve the problem by making one source of data the correct record. For instance, I would make the allocation the source, and then put a callback on allocation that notifies Book of a change. Then, Book can recalculate itself from the allocations. This type of things