Close
Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

PIVOTAL LABS
Standup 2010.10.4 getting SWFUpload to work with Rails 3

Help

“We’re trying to use SWFUpload in Rails 3 by using Rack middleware to rewrite the session cookie passed in via request param. In a Rails 2.3.x your Rack middleware could clobber the session cookie and reset it before it hits your main app. However, this isn’t happening in Rails 3. Has anybody run into this before?”

The answer is that as of Rails 2.3.4, the session handler was moved to Rack middleware. So you need to make sure that your middleware manipulating the session is running before the Rails session middleware is run. You can do this with something like this:

config.middleware.insert_before(config.session_store, FlashSessionCookieMiddleware)

Brian Racer has a good description of getting SWFUpload working with rails 2.3.4

Comments
  1. Nate Clark says:

    We ran into this problem too. Here’s a gist of our (simplified) setup:

    http://gist.github.com/610974

  2. Rajan Agaskar says:

    HAH.

    After picking up one of my side projects for the first time in months a few weeks ago, I found all my flash uploads were getting 422’s (bad auth token). I wasn’t able to resolve after an hour or two of troubleshooting. Spotted this running on our default screensaver a couple days ago and made a note to check it out.

    I was previously just throwing the session and authenticity token in the query params and at this point have no idea how my code was ever working (maybe GET authenticity tokens were previously legit but now no longer?, maybe authenticity wasn’t checked in dev mode?). Either way, after switching to SWFUpload post params (was previously using a specially constructed URL, which was a pretty ugly solution) everything works again. Blabs ftw.

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *