First, you need to add pry-debugger to your Gemfile:

ruby Gemfile gem 'pry-debugger'

Next, create a middleware to trigger pry:

```ruby lib/pry_initializer.rb class PryInitializer def initialize(app) @app = app end

def call(env) binding.pry @app.call(env) end end ```

Now let's configure our app to use this middleware right at the start:

```ruby config/application.rb

...

require 'pry_initializer' config.middleware.insert_after Rack::ETag, PryInitializer

...

run `rake middleware` to see if the middleware is on the correct place. Now when you make requests after restarting the server, you should get a pry promt in which you can enter e.g.

```ruby
break Rails::Rack::Logger#call

# or if you use devise:

break Warden::Manager#call

# or if you use omniauth:

break OmniAuth::Strategies::Facebook#call

Pay attention though, if you hook in your middleware too early, you get errors like: FATAL: Pry failed to get user input using "Readline".. If you know how to get around them, I'd appreciate a comment :)