Wednesday, November 3, 2010

Lost in Transaction

I am working on an issue tracking system at work. I built in an API so other systems can create events, but I wanted to make sure to minimize duplicate events, and opted to just add a comment in case the same issue was opened twice (or more.)

I started with this test

Then wrote this code:

But it kept failing, which was weird to me, because it seemed right.. it wasn't until I tried it from the development environment and checked out the logs that I saw what was happening..

The whole request was being wrapped in a transaction and being rolled back.. A little google searching later, I found after_rollback, and wrote a new callback

And now everything is working as intended. So if you run into a similar situation, I hope that this will help out.

No comments:

Post a Comment