Thursday, December 20, 2012

Rails 2.3 after_create callback doesn't rollback even if returned false

So, this is another mind-boggling thing i came across yesterday. I am working on rails 2.3.11

So i had some after_create callbacks on my app's Order model.

The problem i faced was even when the callbacks would fail, the order was still created and the changes would't ROLLBACK!!



After searching and searching and then searching some more, i happened to look at Rails 3 documentation for after_create callbacks, which stated that if an after_create callback fails, things DON'T ROLLBACK!!

So i figured this might be the reason for the after_create callback not rolling back on failure.

The only thing done on failure of an after_create callback is that "No further execution of code takes place, the chain is halted there and then with no rollbacks"

Weird innit!! And this is stated nowhere in the Rails 2.3 Documentation.

Hope this helps :)


No comments:

Post a Comment