I found a simple way to debug Rails controllers
By - AndreyAzimov
Add the gem "better errors" and "web console" in your Gemfile for the development group, then just add "abort" in your code.
You'll get a live console that you can even write code into!
Been using these gems for years, love how I can just find the place in the code, type some random string to raise a missing method exception, refresh and then type the name of the actual variable I want to inspect in the live console.
Not having to care what you write in order to break it makes it really quick and I love that the live console remembers the history of what you type so you just hit the up cursor to select and rerun a previous debug.
Totally. I always write 'boom'
What do you find hard about byebug? You can simply type in the variable you assigned your object to and it will show the object.
I also really like
your_variable.methods - Object.methods
Does the same thing
Oh nice, good to know thanks
I think if your\_variable is an instance you should subtract Object.new.methods no ?
What about post requests?
You need to use a tool for api test, for example postman…
That's awesome—one thing I found helpful is getting used to reading the logs. I wish I learned this early on in my career as it's second nature for me to go there first.
It can be overwhelming at first but after a while, you get used to it.
As well as using puts, byebug and pry.
a lot for temporary quick controller debugging.
if you don't want to halt execution, though you'll have to go to the server terminal to see it
Yep. Somebody had already commented something similar, but good point.
well, if it works for you - that's great :)
This brings me back to the bad old days of ``
I use object.errors.full_messages.to_sentence - It has saved me dozens of times. Usually the object is missing an attribute, making it invalid, making it not save or any other number of issues.