Closed dhwanitgupta closed 2 years ago
What I had to do was add the following to my Workflow model:
workflow do
...
on_transition do |from, to, event, *event_args|
self.update_attribute(:status, to)
end
end
It's a bit of a hack, but it ensures that the callbacks get triggered on every state transition. Been using it for quite a while now and haven't had any issues with it. Make sure that :status
is the name of your state
attribute.
@geekq This issue can be closed, as the solution provided by @asanger is perfect.
Hi
Problem: To log changes in any model I am using after_commit callback if active record, but when I change state using event then I am not able to use after_commit callback. Is there any way to handle this ?
Basically I want to log any change in model, as after_commit only runs after transaction block is successfully executed therefore I am using after_commit callback
Any help ?