Skip navigation

Monthly Archives: March 2011

I recently had the following error while configuring Nginx with Unicorn on Rails 2.3.8

in my, I had the following:

(taken from the Ruby on Rack instructions on the ‘official’ guide page, )
require “config/environment”

use Rails::Rack::LogTailer
use ActionDispatch::Static

This was giving the following annoying error when trying to start the unicorn server:

/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:443:in `load_missing_constant’: uninitialized constant ActionDispatch (NameError)
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:80:in `const_missing’
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:92:in `const_missing’
from /usr/lib/ruby/gems/1.8/gems/rack-1.1.2/lib/rack/builder.rb:46:in `instance_eval’
from /usr/lib/ruby/gems/1.8/gems/rack-1.1.2/lib/rack/builder.rb:46:in `initialize’
from `new’

It turns out that a patch submitted to unicorn_rails gave the hint ( )

The fix was to replace the line #use ActionDispatch::Static with:
use Rails::Rack::Static

The new thus became:
use Rails::Rack::LogTailer
use Rails::Rack::Static

I am guessing this had to be done because ActionDispatch::Static isn’t present in this version of Rails.