views:

109

answers:

1

I am trying to get Uploadify working with Rails 3. However, I can't insert the middleware with the correct arguments.

This is the Rails 2 way:

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

This is what I have so far for Rails 3:

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

However, this gives:

kevin$hephaestus:$exposure [1035 | 0]% rake middleware                                                        
(in /Users/kevin/Projects/exposure)
rake aborted!
protected method `session_options' called for #<Rails::Application::Configuration:0x101eb28d0>

(See full trace by running task with --trace)
zsh: exit 1     rake middleware

When I comment out the session_options argument, the middleware is successfully inserted, but it can't do what it is supposed to.

Any suggestions?

A: 

I realize this post is 4 months old but I ran into some issues with resolving this issue, adding the middleware on Rails 3. The following is the correct way to accomplish this in Rails 3:

Rails.application.config.middleware.insert_before(
  ActionDispatch::Session::CookieStore,
  FlashSessionCookieMiddleware,
  Rails.application.config.session_options[:key]
)

http://gist.github.com/546431

Damian Galarza