Using binding.pry in Rails app's view or partial Using binding.pry in Rails app's view or partial ruby-on-rails ruby-on-rails

Using binding.pry in Rails app's view or partial


It's always worked for me... you might need to require it.

<% require 'pry'; binding.pry %>


<% binding.pry %> works well.

It doesn't work only if you didn't install pry-rails gem in your rails app.

Please post the error that you are facing if use <% binding.pry %> such that I can elaborate it more.


I realize this question is now dated, but wanted to raise one other possibility here. It is also possible that your app is breaking before reaching the line of code in which you've placed <%binding.pry%>. If you are not hitting pry (and have confirmed that it is in your Gemfile and that you've run bundle install), consider moving <%binding.pry%> a few lines higher up in your code. If you still do not hit it, consider repeating this process. If you've worked your way to the first line of the view and still aren't hitting pry, try working backward to the controller action that controls rendering this view. If pry is indeed bundled, a common reason for not hitting pry is the app breaking. Again, posting the error here always helps.