How do I update middleware for Rails 3?

Hello,

I'm updating an application to Rails 3 that has Uploadify implemented as described by John Nunemaker here: http://railstips.org/blog/archives/2009/07/21/uploadify-and-rails23/

My questions are:

1) Where should middleware live in a Rails 3 application? app/middleware?

2) Is the middleware path loaded in config/application.rb? Or is there a way to do it in config/environment.rb?

3) What should I update the following code to to make it work in Rails 3?

# config/initializers/session_store.rb

ActionController::Dispatcher.middleware.insert_before(   ActionController::Session::CookieStore,   FlashSessionCookieMiddleware,   ActionController::Base.session_options[:key] )

Specifically, how do I call each of the following:

- ActionController::Dispatcher.middleware.insert_before - ActionController::Session::CookieStore - ActionController::Base.session_options[:key]

I've looked through the Rails 3 source, and tried various combinations e.g., ActionDispatch::Cookies, ActionDispatch::Middleware::Cookies, ActionController.cookies, etc., but to no avail.

Thanks, Patrick

hi, Patrick. Try the following code, it works for me.

replace # config/initializers/session_store.rb

ActionController::Dispatcher.middleware.insert_before(   ActionController::Session::CookieStore,   FlashSessionCookieMiddleware,   ActionController::Base.session_options[:key] )

with

Rails.application.config.middleware.insert_before(Rails.application.config.session_store, FlashSessionCookieMiddleware, Rails.application.config.session_options[:key])