I have a gem, and part of the gem is a piece of rack middleware. In Rails 2.3, I could make the gem set up the middleware without adding anything to config/*.rb in the app. I did this with the following line:
ActionController::Dispatcher.middleware.use 'MyMiddleware'
But in Rails 3, this doesn't work.
I've tried putting the following into the gem's lib/gem_name.rb:
Rails.application.config.middleware.use 'MyMiddleware'
But now when I run `rake middleware` I get "undefined method `config' for nil:NilClass" which means that Rails.application is nil.
I successfully used the middleware by with an initializer or something in the app's config directory, but I'd like to do this in the gem. Is this possible?