I have a pretty strange problem. Here is basically what I have to
demonstrate my problem:
class Event < ActiveRecord::Base
class AnotherClass < ActiveRecord::Base
e = Event.find event_id
Here is the catch 22 and it’s quite annoying. Basically ActiveRecord
puts to whole save action into a transaction. If an exception is
raised in the after_create method it rolls back the transaction, as
if the save never happened. The problem is that during the
transaction the save is never committed to the database. So
AnotherClass.find_event raises the exception “Can’t find event with
id=34” or whatever id it had, because the transaction hasn’t been
committed. That exception then rolls back the transaction, creating a
So basically what I’m asking if there an after_after_create method?
ha ha. Basically a method that gets called after the transaction is
Also, in case you were wondering I did set up an EventObserver and
get the same exact problem.
Lastly, I can not pass the object because AnotherClass is in a
background process and passing methods between processes is not
permitted. I’m using backgroundrb for this.
Any help is greatly appreciated.
E: [email protected]