Debugging Rails Apps Flashcards
How can you print variable info to the view?
< % = debug @variable % >
What is the easiest way to display an array or hash, x, in a view?
x.inspect
How do you add byebug to a project?
Add it to the gem file in the development and test groups only.
group :development, :test do
gem ‘byebug’, ‘9.0.6’, platform: :mri
end
How do you add a breakpoint in the code with byebug
Put the ‘byebug’ command on the line where you want to stop the code. After that you can add breakpoints at the command line.
How can you get a list of the byebug commands?
Type ‘help’ in the byebug console
Whats the difference between step and next in byebug?
The next command will take you to the next line of code in the controller, step will take you to the next command to be executed, where ever that it in the program.
How can you bring up a web console in a view or controller?
In a controller add a line with the following command
console
in a view use the following
< % console % >
How can you list all the instance variables with web-console?
> > instance_variables
Where do you add web-console to the gem file?
in the development group
group :development do
gem ‘web-console’
end