I have an observer and I register an after_commit
callback.
How can I tell weather it was fired after create or update?
I can tell an item was destroyed by asking item.destroyed?
.
I was going to solve it by adding after_create
/after_update
and do
something like @action = :create
inside and check the @action
at
after_commit
, but it seems that the observer instance is a singleton
and I might just override a value before it gets to the
after_commit
. So I solved it in an uglier way, storing the action in
a map based on the item.id on after_create/update and checking its
value on after_commit. Really ugly.
Is there any other way?