Rails app demonstrating multiple file uploads
JavaScript Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
config Initial commit Apr 21, 2012
db
lib Initial commit Apr 21, 2012
log Initial commit Apr 21, 2012
public Initial commit Apr 21, 2012
script Initial commit Apr 21, 2012
test
vendor
.gitignore
Gemfile
Gemfile.lock
README.rdoc readme and cleanup Apr 21, 2012
Rakefile Initial commit Apr 21, 2012
config.ru

README.rdoc

Sample App: CarrierWave Multiple File Upload

This app demonstrates an example of how to use the CarrierWave gem to facilitate multiple file uploads. This is a Rails 3.2.3 application that uses Ruby 1.9.3 and was developed on Mac Lion OS X.

CarrierWave is easy to set up and by default allows just one file to be uploaded at a time. To upload more than one file at a time, I've made use of the Jquery-File-Upload plugin. This plugin expects a json response and uses AJAX to update the page with the upload results. To facilitate the creation of a json response, I use the Jbuilder gem.

The example here has two models, Gallery and Photos. Gallery has many Photos. Photo belongs to Gallery. Since these two models are nested, I took the nested resources approach.

Since we're uploading image files, we'll want to use a gem called MiniMagick which is a Ruby wrapper for ImageMagick. Use HomeBrew to install ImageMagick: brew install imagemagick.

One side note regarding Carrierwave: when photos are deleted, the corresponding file folders become empty, but are not removed. This is a Carrierwave “feature”, and work-arounds can be found online. Paperclip, another popular upload gem cleans up its folders nicely and is easy to use as well.