0

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

2
  • It's possible, just use a local version of Rails and put debug code there. But it's rarely necessary. In most cases the problem is in your own code. You can post your own code and error message to see if somebody could help. Commented Aug 25, 2013 at 11:23
  • Use RubyMine IDE, there is an internal debugger Commented Aug 25, 2013 at 12:26

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

fantastic this is what I was looking for, do you have a clue how I can do a "step into" that instead of 'next' moves me inside the execution of a method? thanks a lot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.