Friday, April 15, 2011

Configure Rack-bug for rails 3

While migrating one of my rails application on rails 3, I thought of using rack-bug simultaneously for improving performance.

Following are the steps which I used for configuring rack-bug for rails 3 (3.0.6).

1. Install rack-bug (branch rails3) as plugin
   cd vendor/plugins
   git clone -b rails3

If you want to you it as gem then add following line into Gemfile
gem 'rack-bug', :git => '', :branch => 'rails3'

2. Replace the code from file actionview_extension.rb
which is avilable in vendor/plugins/rack-bug/lib/rack/bug/panels/templates_panel/ as specified in bug of rack_bug repository

if defined?(ActionView) && defined?(ActionView::Template)
  ActionView::Template.class_eval do
    def render_with_rack_bug(*args, &block)
      Rack::Bug::TemplatesPanel.record(virtual_path) do
        render_without_rack_bug(*args, &block)
    alias_method_chain :render, :rack_bug

If you are using gem override the specified file in some way

3. Add following lines into your
   require 'rack/bug'
   use Rack::Bug, :secret_key => "someverylongandveryhardtoguesspreferablyrandomstring"
   run myapp

4. Start your server and access the URL http://your_app/__rack_bug__/bookmarklet.html
   and enter the password.

No comments:

Post a Comment