Home Run after_rollback callback for rollbacks due to another callback
Reply: 1

Run after_rollback callback for rollbacks due to another callback

Keerthana Raghavan
1#
Keerthana Raghavan Published in 2018-01-09 12:08:07Z

I want to raise a dummy exception while doing 'save'(while creating) and see if the method in after_rollback callback works fine.

I'm doing something like this:

before_create :do_something
after_create :raise_exception
after_rollback :revert_method

Here, rollback is happening, but revert_method in after_rollback isn't executed.

(I want the before_create callbacks to run as well, so cannot raise the exception before that.)

Amr El Bakry
2#
Amr El Bakry Reply to 2018-01-13 20:25:16Z

You could use a debugger like the Byebug gem to follow and inspect the flow of your application step by step.

See Rails Guides section Debugging with the byebug gem

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.30699 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO