[Rails] telling app to use middleware in gem
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?
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home