Please can you share your approach / methodology to debugging in Ruby / Rails.
I'm busy with the Rails tutorial, and am getting the error:
NoMethodError in UsersController#show
undefined method `microposts' for #<User:0x83b43e8>
I haven't seen this mentioned yet but another option is to put a
debugger statement in your code. Like this
def some_method something = 3 debugger # ... more code end
If this is in a rails app when the code reaches
debugger it will cause the terminal window running the web server to jump into something that looks like an irb session (I'm not exactly sure what it is). From there you can do
puts something to see what the value is for example. You can even
puts params to see what all the params values are. You can also step through the code, jump to a specific line, etc.
Pry seems to be a better way to go about this but it's how I used to debug before I knew about pry.
Note: You might need to do
require 'ruby-debug' if you're doing this outside of rails.