Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding.pry in controllers with passenger

I try use binding.pry in controller file and when i reload page, passenger stuck on it but irb doesn't work (It shows up, but stuck. It looks like passenger wrote string and thats all.). On passenger site we can read, that irb is for business plan but if we use binding.remote_pry(binding.pry ignored by rails 3), it works great. Of course binding.pry works great for WEBrick. The question is, if i'm right or it's possible to use the binding.pry with passenger but i have to write something somewhere to make it work?

Second objective of this topic is to put the link above, and this for the next beginners. I spent a lot of time to find the answer, why it doesn't work and what to do to make it work.

By the way - whether we can still somehow debugging/live debugging controllers/views? I found this but didn't try.

I use rails 4.

like image 949
Dariusz Gardyński Avatar asked Sep 01 '14 12:09

Dariusz Gardyński


People also ask

Where should binding pry be placed?

Now to use Pry, you'll first have to install it in your environment. You can either put gem 'pry' in your Gemfile and bundle install, or manually type gem install pry into your terminal. After we've installed it, then we'll have to require it in our environment with the line require 'pry' , write binding.

How does binding pry work?

Calling binding. pry is essentially 'prying' into the current binding or context of the code, from outside your file. So when you place the line binding. pry in your code, that line will get interpreted at runtime (as your program is executed).

How do I stop binding on pry?

To exit everything, use: exit! This should ignore all proceeding bindings. This also kills the server at the same time.

Why is binding pry not working?

To fix this just move the binding. pry command one line to the top and try to run your file again. If it still doesn't catch it, move the binding. pry command one more line to the top and keep doing this until your file catches the binding.


1 Answers

When execution stops at binding.remote_pry in passenger, it will wait for you to connect to the debugger with the pry-remote client. From a shell on the same machine, just run:

pry-remote
like image 173
infused Avatar answered Sep 29 '22 04:09

infused