If you’re running Ruby 1.9.1, you might have problems installing the latest version of Ruby-debug (as of this writing), which now requires
linecache19 — a gem that itself has a dependency on Ruby >= 1.9.2. With a little hacking, I managed to fork a version of Mark Moseley’s awesome
ruby-debug19 and patched it for legacy applications that need to run on 1.9.1.
To install, use the following ordered dependencies in your Gemfile (if you’re using Bundler):
1 2 3
Subsequently, you should be able to launch an inline debugger at server-launch time:
1 2 3 4 5 6 7 8
When you want to inspect specific variables, insert debug slugs like so in a Rails view to pause execution of the Ruby engine mid-template:
1 2 3
On page load, launch an IRB session to interact to inspect the current state of execution:
Now, feel free to execute arbitrary Ruby code, within the scope you embedded a debugger in.
For more documentation, refer to the ruby-debug Command Syntax.