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.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJan 12, '12 at 7:56a
activeJan 12, '12 at 7:56a
posts1
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

Vlad: 1 post

People

Translate

site design / logo © 2021 Grokbase