Skip navigation

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

in my config.ru, I had the following:

(taken from the Ruby on Rack instructions on the ‘official’ guide page, http://guides.rubyonrails.org/rails_on_rack.html )
config.ru
======
require “config/environment”

use Rails::Rack::LogTailer
use ActionDispatch::Static
run ActionController::Dispatcher.new

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 config.ru:5
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 config.ru:1:in `new’
from config.ru:1

It turns out that a patch submitted to unicorn_rails gave the hint (http://bogomips.org/unicorn.git/diff/bin/unicorn_rails?h=body-keepalive&id2=98ea5cca50b907e20d6357f425d7789bac1d1a47 )

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

The new config.ru thus became:
use Rails::Rack::LogTailer
use Rails::Rack::Static
run ActionController::Dispatcher.new

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

Advertisements

One Comment

  1. Thanks for posting your solution! I was having the same issue (uninitialized constant ActionDispatch) setting up redmine 1.2 (actually current trunk) on ruby 1.8.7 and rails 2.3.14 behind nginx and unicorn. I too had used the example rackup config from the Rails on Rack guide.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: