Rails 3, Mongoid, Carrierwave, and Uploadify
This is a demonstration application using:
- Rails 3.0 — Best web framework ever
- Mongoid — A MongoDB mapper for Rails
- Carrierwave — Upload and attach files to Rails models
- Uploadify — Flash based multi-file uploader
- RSpec 2.0 — Works well with Mongoid
- JQuery 1.4.1 — Prototype replacement, required by Uploadify
- jQuery-UI 1.8.4 — Used for drag and drop sorting of photos
- HAML — Much better than writing in ERB
- RemarkableMongoid — Very useful in testing standard Mongoid associations
- Configuration to use Amazon S3
JQuery plugin that uses SWFObject to easily select and upload multiple files. Sensible defaults, good looking default buttons, excellent callback mechanism.
Uploading mechanism using Rack Middleware to handle accept uploads and “mount” them to the model. Carrierwave is best at isolating all uploading functions from the model it’s being attached to. Image is the mount point inside the photo model. The photo model is an embedded document inside the story model.
Mongoid is an excellent (and we think the best) ORM for MongoDB. It enables embedded documents as well as ActiveRecord style associations (called references). The documentation is good and is actively developed. It does not interfere with ActiveRecord so projects can use both in parallel.
The jQuery UJS project for Rails lists 1.4.1 as the recommended version for Rails 3.0.
App includes configuration to use S3 for production, :file for development, and :file without processing in test mode. See config/initializers/carrierwave.rb for details.
- Stores photo width and height
- Stores photo orientation
- Live photo sorting using jQuery sortable