I've been trying to migrate my codebase from rails 5 to rails 7 and there are some issues with callbacks which I'm unable to figure out
Issues:
- When multiple callbacks like
after_create_commit
andafter_update_commit
are supposed to trigger the same method sayfoo
the method doesn't get called. For example:
after_create_commit :foo
after_update_commit :foo
But it does when I slightly change the syntax as
after_create_commit -> { foo }
after_update_commit -> { foo }
- If there are multiple methods to be triggered after a callback then only the last one gets called and all the ones before it doesn't get executed, For example:
after_create_commit :foo1
after_create_commit :foo2
after_create_commit :foo3
here only foo3
gets executed and foo1
, foo2
doesn't.
can someone explain this behaviour and what could be the proper solution for this?