Reputation: 3304
I've got an issue (this one: How to pass multiple locals to a nested partial) with rails and to figure out what's going on I need to debug the rails internals.
I need to understand which conditions raise the exception in the file
actionpack (3.2.14) lib/action_view/template.rb
At line: 145
How can I debug the framework? I tried to use logger.debug, but it's not available, and I tried with puts, but the console isn't set.
Thanks in advance
Upvotes: 0
Views: 249
Reputation: 3737
Use Pry gem! It is an excellent debugging tool which is easy to setup and has some where powerful features..
Just add 'pry' and 'pry-debugger' gems to your Gemfile (test group) and run bundle
and restart the server. After that you just need to set the breakpoint inside your code with command binding.pry
. In your case you would want to add breakpoint in your main view with this line:
<% binding.pry %>
Now just trigger the request and the terminal in which you are running the server will stop, giving you prompt so you can interact with the code like in rails console. You have some standard navigation commands such as 'continue', 'next', 'step', 'finish'... you can view the code around you with 'whereami' command, or list the source of methods and classes.
I suggest taking a look at this Pry railscast for more information on how to use Pry.
Upvotes: 1