Carrierwave makes it easy to attach files to Rails models, but all the uploading magic operates synchronously. If you're using Backbone and want to keep model updates asynchronous, it may seem like you're out of luck.
You're not. The new XMLHttpRequest spec, which you may know better as AJAX, supports an interface called FormData. This uses the same format as a synchronous form submitted with its type set to multipart/form-data, which is what enables file uploads in a regular, synchronous form. Make sure your target browsers support FormData.
Say you have a User model with a Carrierwave field called :avatar. The update action of your RESTful controller might look like this:
Backbone is not a very opinionated framework. It's super useful and we love it, but it definitely gives you enough rope to hang yourself (and then-some).
We at Quick Left have done battle against the likes of spaghetti DOM code and phantom views, and lived to tell the tale. Here's a new nugget from our adventures: Idempotent View Rendering
Rocky Mountain Ruby is less than a week away and the team at Quick Left is getting ready. In case you haven't heard, we're running an Intro to Backbone.js workshop on Saturday 9/22. We had so much fun doing this workshop in San Francisco last week that we're gettin' crazy - we're giving away a ticket to one lucky person and setting up a discount for everybody else!
On Saturday, Sept. 8th, our Backbone.js training is kicking off in San Francisco. Our friends over at Singly
have graciously agreed to host us, so we'll be setting up shop right in the Mission district of SF.