Using a gem named pry you can easily inspect the state of your web application while it's running with the
Let's see how.
Let's start by adding pry to your Gemfile.
(Don't forget to
bundle install afterwards)
# Gemfile gem "pry" gem "pry-remote"
Then in your config.ru you just need to require pry-remote.
# config.ru require 'pry-remote'
Next let's go to our Sinatra app, and put
binding.remote_pry wherever it is you want to start your pry session.
# app.rb get '/' do # some really complicated and convoluted code that makes your head hurt binding.remote_pry end
Now just hit the
/ route on your application.
You will notice that the browser will hang without rendering the page, that's because a pry-remote session was started.
To access it go to your command line and type:
$ pry-remote From: /Users/locks/repo/api.rb @ line 15 self.GET /: 10: 11: get '/' do 12: # some really complicated and convoluted code that makes your head hurt 14: => 15: binding.remote_pry 17: 16: end
And now you're ready to have fun!