views:

344

answers:

1

I was able to do the following in Rails 2.3.5 to access attributes that I set on the session from within my Rails app. Now in Rails 3, env["rack.session"] is nil. How do I do the same thing in Rails 3?

class CallbackFilter
  def initialize(app)
    @app = app
  end

  def call(env)
    unless env["rack.session"][:oauth_callback_method].blank?
      env["REQUEST_METHOD"] = env["rack.session"].delete(:oauth_callback_method).to_s.upcase
    end
    @app.call(env)
  end
end
+1  A: 

It was because I placed the use CallbackFilter in config.ru. It should be placed in config/application.rb like so:

config.middleware.use CallbackFilter

Otherwise the environments didn't look like they were in sync...

viatropos