When you get an Exception you may feel like the resulting web page is a bit cryptic. E.g. it looks like this:
Title: Action Controller: Exception caught
Message: NoMethodError in SomeController#index
undefined method some_method' for nil:NilClass
Rails.root: /path/to/your/app
Then, typically you'll see a bunch of links with more information such as:
1. Application Trace
This shows the exact line that created the exception.
Go and locate this line.
2. Framework Trace
e.g.
actionpack (3.2.9) lib/action_controller/metal/implicit_render.rb:4:in send_action’
Each line tells you 3 things about the error:
2.1 the file it occurred in: implicit_render.rb
2.2 the line it occurred in: 4
2.3 the method it occurred in: send_action
The Rails framework is pretty well tested so you can ignore errors there. Work your way down to your code.
3. Full Trace
Below these you’ll see the Request section along with links for Session and Env dumps:
4. Show session dump
5. Show env dump
Finally, you’ll see any Response headers.
Resources
Debugging Rails Applications:
http://guides.rubyonrails.org/debugging_rails_applications.html
For example, using the Rails debugger is very helpful.
Install the ruby-debug gem, put ‘debugger’ at the point you want to debug, and start Rails with ‘rails s –debugger’.