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

4

22

Pry is quite amazing in my R3 app. But any chance I can use

<% binding.pry %> 

in a view or a partial like I did previously with

<% debugger %>

This doesn't seem to work. Thanks.

Aurilia answered 29/1, 2013 at 15:49 Comment(1)
ahh posted this too quick. i had another thing here. verified it just works :)Aurilia
A
31

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

<% require 'pry'; binding.pry %>
Abele answered 29/1, 2013 at 15:55 Comment(0)
C
8

<% 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.

Contravention answered 4/4, 2014 at 11:49 Comment(1)
Cool anyway it worked for you. Didn't see your comment below your question.Contravention
I
2

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.

Indication answered 23/3, 2021 at 4:1 Comment(0)
R
0

Or even better, I like to pass in PRY as an environmental var so I don't have to delete all the requires!

<% binding.pry %>

&&

$ PRY=true rails s
Refection answered 6/8, 2013 at 21:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.