I just got hit by this famous error again. And I am not the only one:

Now, I know I should put my patches where my mouth is. And that’s exactly what I’m trying to do here. My application is on the 1.2 branch, and I get this error if I have the Response Logger plugin loaded. Trying again with Edge Rails, I again get the error. If I try with WEBrick or Mongrel, same error. Loading the console produces the same error. Using Windows or Linux changes nothing: same error.

The exact backtrace is:

1 $ ruby script\console
2 Loading development environment.
3 ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:249:in `load_missing_constant’: Expected ./script/../config/../config/../vendor/plugins/response_logger/lib/response_logger.rb to define ResponseLogger (LoadError)
4 from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:452:in `const_missing’
5 from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:464:in `const_missing’
6 from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:260:in `load_missing_constant’
7 from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:452:in `const_missing’
8 from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:260:in `load_missing_constant’
9 from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:452:in `const_missing’
10 from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:260:in `load_missing_constant’
11 from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:468:in `const_missing’
12 … 14 levels…
13 from C:/ruby/lib/ruby/1.8/irb/init.rb:250:in `load_modules’
14 from C:/ruby/lib/ruby/1.8/irb/init.rb:21:in `setup’
15 from C:/ruby/lib/ruby/1.8/irb.rb:54:in `start’
16 from C:/ruby/bin/irb.bat:20

In this application, I am using Engines, along with LoginEngine. You really need the right version of Engines with the right version of Rails for things to work out well: Rails 1.2 requires Engines 1.2.

Engine Generator


This article is obsolete now that Rails 2.3 has Engines in core.

Jon Lim on the Rails mailing list just announced the release of Engines Generator.

From the documentation:

$ script/generate engine UploadEngine
Please enter the author’s name: Joe Smith
Please enter the author’s email: joe.smith@xyz.com

We can generate the following licenses automatically for you:
0) None
1) GPL
2) MIT
Please select a license: 2
‘MIT’ selected
exists vendor/plugins
create vendor/plugins/upload_engine
create vendor/plugins/upload_engine/README
create vendor/plugins/upload_engine/init_engine.rb
create vendor/plugins/upload_engine/app
create vendor/plugins/upload_engine/app/models
create vendor/plugins/upload_engine/app/controllers
create vendor/plugins/upload_engine/app/helpers
create vendor/plugins/upload_engine/app/views
create vendor/plugins/upload_engine/db
create vendor/plugins/upload_engine/db/migrate
create vendor/plugins/upload_engine/lib
create vendor/plugins/upload_engine/lib/upload_engine.rb
create vendor/plugins/upload_engine/lib/upload_engine
create vendor/plugins/upload_engine/public
create vendor/plugins/upload_engine/public/javascripts
create vendor/plugins/upload_engine/public/javascripts/upload_engine.js
create vendor/plugins/upload_engine/public/stylesheets
create vendor/plugins/upload_engine/public/stylesheets/upload_engine.css
create vendor/plugins/upload_engine/tasks
create vendor/plugins/upload_engine/tasks/upload_engine.rake
create vendor/plugins/upload_engine/test
create vendor/plugins/upload_engine/test/test_helper.rb
create vendor/plugins/upload_engine/test/fixtures
create vendor/plugins/upload_engine/test/functional
create vendor/plugins/upload_engine/test/unit

$ mv app/models/upload.rb vendor/plugins/upload_engine/app/models
$ mv app/controllers/upload_controller.rb vendor/plugins/upload_engine/app/controllers
$ mv app/views/upload vendor/plugins/upload_engine/app/views
$ mv public/javascripts/upload_engine.js vendor/plugins/upload_engine/public/javascripts
$ mv public/stylesheets/upload_engine.css vendor/plugins/upload_engine/public/stylesheets


1 Engines.start :upload_engine

$ script/server

This is way cool. Great work, Jon !

This article is obsolete now that Rails 2.3 has Engines in core.

I learned a nice one today. If you use Rails Engines and you want to configure your environments differently, you can’t do this:


1 module LoginEngine
2 config :salt => test
3 end


1 module LoginEngine
2 config :salt => a-long-and-complicated-salt
3 end


1 Engines.start :login

If you do that, you’ll get the following backtrace:

1 $ ruby script\server
2 ./script/../config/../vendor/rails/railties/lib/initializer.rb:178:in
3 `load_environment’: undefined method `config’ for
4 Rails::Initializer::LoginEngine:Module (NoMethodError)
5 from ./script/../config/../vendor/rails/railties/lib/initializer.rb:150:in `load_environment’
6 from ./script/../config/../vendor/rails/railties/lib/initializer.rb:147:in `silence_warnings’
7 from ./script/../config/../vendor/rails/railties/lib/initializer.rb:147:in `load_environment’
8 from ./script/../config/../vendor/rails/railties/lib/initializer.rb:73:in `process’
9 from ./script/../config/../vendor/rails/railties/lib/initializer.rb:36:in `send’
10 from ./script/../config/../vendor/rails/railties/lib/initializer.rb:36:in `run’
11 from ./script/../config/../config/environment.rb:10
12 from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require__’
13 from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require’
14 from ./script/../config/../vendor/rails/railties/lib/commands/server.rb:52
15 from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require__’
16 from C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require’
17 from script/server:3

What is happening is that Rails loads the environment file before the Rails Engine plugin is initialized. The solution ? Do everything in config/environment.rb:


1 module LoginEngine
2 case RAILS_ENV
3 when development, test
4 config :salt, "test"
5 when production
6 config :salt, "another-long-and-complicated-salt"
7 end
8 end
10 Engines.start :login

This article is obsolete now that Rails 2.3 has Engines in core.

Over on the Rails mailing list, James Adams reports the initial release of Rails Engines.

What are engines ? They are plugins, more or less, except they also bundle controllers, views, partials, models and everything else you’d usually need in a component.

In fact, Rails Components could very well be implemented using Rails Engines.

I wonder how routes are handled. Can engines provide their own routes, or must the engine user define the routes he wants ? Gotta try that login_engine and see for myself.


Your Host

A picture of me

I am François Beausoleil, a Ruby on Rails and Scala developer. During the day, I work on Seevibes, a platform to measure social interactions related to TV shows. At night, I am interested many things. Read my biography.

Top Tags

Books I read and recommend


Projects I work on

Projects I worked on