Upload
avi-kedar
View
98
Download
1
Embed Size (px)
Citation preview
Rails Debugging
Use View Helpers
<%= debug @post %>
<%= [1, 2, 3, 4, 5].inspect %>
Use The Logger
logger.debug "Person attributes hash: #{@person.attributes.inspect}“
logger.info "Processing the request...“
logger.fatal "Terminating application, raised unrecoverable error!!!"
Log levels: (debug|info|warn|error|fatal)
Use Rails Debugger1. install group :development do
gem 'debugger' end
2. Call ‘debugger’ action inside ruby code to add break point
3. Run ‘rails s --debugger’
List Command1. Use list or l (shorthand)
2. ‘l=‘ to see the current breakpoint with 5 previous and 5 next code lines
3. ‘l’ to see the next 10 code lines
4. ‘l-’ to see the previous 10 code lines
More Commands
***Use ‘help’!***
1. ‘instance_variables’ – return array of all the instance variables
2. ‘next’ – execute the current line
3. ‘c’ (continue) – resume the execution
4. ‘where’ - see the stacktrace