Pry is probably the best debugging tool currently available for ruby applications, and when used in conjunction with good old rails c, debugging Rails is pretty straightforward.
I recommend adding the gem jazz_hands to your Gemfile. It includes pry along with bunch of other little goodies for sprucing up your console.
From there itās simply of matter of dropping binding.pry somewhere in your code and getting the interpreter to eventually evaluate it. E.g.,
class MyObj
def do_stuff
binding.pry
....
end
end
And then in your ruby console you can start your pry session via:
It essentially grants you break point capabilities for your ruby projects, extremely useful for debugging object state during runtime. I wish I could speak more intelligently on how it can be used, but so far Iāve only ever really needed to use it for basic things and itās done a hell of a job at it. I know thereās other gems like pry-byebug that extend this even further if you really want to pull your code a part and see what happens at each level of the call stack.
If you just want a step up from the poor manās style of debugging (good old puts) another thing I find myself doing is simply calling raise somewhere in my application during development. Since Iām using the better_errors gem with binding_of_caller I get a spiffy error panel with a REPL prompt that allows me to see the value of local variables. It isnāt elegant, but it works, and it sure beats the hell out of calling puts everywhere.
@Cyle_Hunter you are right, I love PRY too. And I also use Better Errors. They are both quite beautiful. I just realized recently that with Better Errors, you actually get a REPL for every step of the stack, where you can access local variables and settings within each step. I always just used to use the top of the stack.
That being said, I am now working with much more complicated data relationships and behavior, and I have to be holding everything in my head - to get all the relationships right. It has gotten to a place where on one operation there are 5+ halts, because I have binding.pry everywhere. That has gotten to be too much.
So I would love if I could basically dump the mental model I have in my mind, into some tool, that will help me visualize everything I am trying to build.
I am not sure if this exists, but just figured I would ask
In fact, I have something in mind that I want built, but I figure I would need hardcore JS skills to be able to build the web version. So if anyone that is particularly strong on the front-end with JS would like to build something like that, then let me know. It would be OSS obviously.
Thereās also a bunch of free UML diagramming tools available on all the major operating systems that should have some of the bells and whistles that youāre looking for.
If you would just like to get a visual of your existing controllers and models you can use RailRaody to dump some diagrams. Hell, if youāre using guard with guard-rake you can even run the rake task for generating the diagrams in an automated fashion if you really wanted.
I joined a really complicated project a few months ago. Rails erd really helped me to understand the logic and I still use the diagrams as reference especially when debugging or working with the console.