This week we had a very deep and hard to track down bug that was only happening
on certain Mac architectures. The problem came down to setting shape object
data on ActiveRecord models and then mysteriously having that field become nil
.
After setting pry breakpoints in several dozen places we still weren’t any closer to solving the problem. The magic meta that ActiveRecord supplies was making it an impossible exercise of patience to step through what seemed to be several hundred stacks of a statement that was this simple on the outside:
|
I ended up writing this class to try to help narrow down our problem, and it turned out to be increddibly helpful!
|
This snoopy class delegates all calls to the target @obj and prints helpful debug information out on what is being called where. Using it like this yielded some amazing information:
|
Here is the output it produced:
|
Using this we were able to quickly narrow down the problem in the postgis adapter gem. If you ever find yourself in this same problem, maybe Snoopy can help you to :)