Rails Debug Toolkit =================== Introduction ------------ `rails_dt` gem gives you `DT.p()` method you can use anywhere in your project to print your debug messages. It's somewhat similar to Ruby's native `p()` with output being sent to log, console and web. For example, `DT.p "Hello, world!"` invoked in `RootController` will give you a: [DT app/controllers/root_controller.rb:3] Hello, world! The Ideas Behind It ------------------- * Debug message printer must **not require initialization**. * Debug message printer must be **nothing else**, but a debug message printer. * Debug message printer must be simple and invoked **always the same way** regardless of where you call it from. * Debug message printer calls must be **clearly visible** in the code. * Debug message printer must **print its location in code** so you can find and modify/remove it as easy as possible. Express Setup (Rails 3) ----------------------- In your `Gemfile`, add: gem "rails_dt" Then do a `bundle install`. This gives you an express (zero-conf) setup, which outputs messages to log, `log/dt.log` and console. Express Setup (Rails 2) ----------------------- $ gem sources --add http://rubygems.org $ gem install rails_dt In your `config/environment.rb`, add: config.gem "rails_dt" Setting Up Web Output (Both Rails 3 and Rails 2) ------------------------------------------------ In your application root, do a: $ rails generate rails_dt # Rails 3 $ script/generate rails_dt # Rails 2 Follow the instructions the generator gives you then. They are listed below. Inside your `ApplicationController` class, add: handles_dt Inside your `app/views/layouts/application.html.erb` `
` section, add: <%= stylesheet_link_tag "dt" %> Inside your `app/views/layouts/application.html.erb` `` section, add: