How to use rjs templates with uploadify: a rails multiple file upload extravaganza!

Starr Horne bio photo By Starr Horne

John Nunemaker posted a great article on using uploadify with rails.

Uploadify is a sweet jquery plugin that lets you do multiple file upload with progress indicators and everything, using the magic of flash.

But you know that magic always comes with a price. Specifically: flash sucks. It sucks in part because it doesn’t let you send cookies back with your request. John’s post showed you a way around that.

But it also sucks because it doesn’t send HTTP request headers either. Which means no RJS, kiddies. Unless you use a workaround like so.

In your middleware:

And in your javascript, you’ll need to add a bit of code to eval the response:

Now, bingo! You can just use responds_to like normal.