Where can I level up in my Ruby debugging? specific example:

In an earlier post I mentioned that I had some trouble with the type column in a rails object not saving properly.

It is safe to say that I and another guy spent at least 10 hours trying to figure out why, and the answer eventually was that another gem, paper trail, was meddling with the object after we called #save on it.

As I lay in bed last night I was happy that we figured out the issue. But I also realized that we were lucky, because I just happened to read the post on stack overflow about paper trail. It was never on page one of any search I made about this problem, and I’m still not sure how I stumbled onto it.

What really bothers me is that when Ruby or Rails does things that are really mysterious, I end up acting like a monkey feeding inputs into a black box and hoping what it spits out will make sense.

I know about pry and byebug, and I can step into the code, but even just calling save on an activerecord object means that you are going to step through thousands of lines of code, and hundreds of methods (it seems). It is hard to zero in on the place where things are going wrong.

Let’s say I have an object called @order. Is there any way to halt execution any time @order.type changes or becomes something unexpected?

I.e, if some of you all-stars had been facing this problem, how would you have gone about finding the problem in the papertrail gem? And where did you learn such? I feel that if I could really strengthen my debugging skills I really could be fearless, but right now I still feel like I’m “outside the box” when things are going wrong.


1 Like

chirp chirp said the little cricket