MongoDB with MongoMapper and Ruby on Rails
MongoDB (from "humongous") is a scalable, high-performance, open source, schema-free, document-oriented database. Written in C++, MongoDB features:
- Document-oriented storage (the simplicity and power of JSON-like data schemas)
- Dynamic queries
- Full index support, extending to inner-objects and embedded arrays
- Query profiling
- Fast, in-place updates
- Efficient storage of binary data large objects (e.g. photos and videos)
- Replication and fail-over support
- Auto-sharding for cloud-level scalability
- MapReduce for complex aggregation
- Commercial Support, Hosting, and Consulting
MongoDB bridges the gap between key-value stores (which are fast and highly scalable) and traditional RDBMS (which provide structured schemas and powerful queries).
Download and run mongod http://www.mongodb.org/display/DOCS/Downloads
- Authentication - Devise http://github.com/plataformatec/devise (just configure the ORM option)
- Image uploading - CarrierWave - http://github.com/jnicklas/carrierwave with a Rails metal or Grip http://github.com/twoism/grip
- Formtastic works http://github.com/justinfrench/formtastic
- and many more - add your favorite in the comments should you know of a good one with MM support
And if that user had comments the model could look like:
These are just to help kick-start your app development, for more complete examples see the open source apps and http://www.mongodb.org/display/DOCS/MongoDB+Data+Modeling+and+Rails : Open Source Ruby Applications using MongoDB (and MongoMapper) NewsMonger - A simple social news application demonstrating MongoDB and Rails
http://github.com/kneath/watchtower/
http://gitorious.org/shapado/shapado
http://gitorious.org/mmmblog More at http://wiki.github.com/jnunemaker/mongomapper/projects-using-mongomapperPro Tips
- MongoMapper uses a fork of the validatable gem - which has some differences with AR validations
- Denormalization is needed to reduce round-trips to the DB
- Change how you think of your data models - this is closer to an object store
- The finders have nifty options checkout http://wiki.github.com/jnunemaker/mongomapper/whats-new (0.5.7)
- Don't be afraid to drop down and use to the Ruby MongoDB driver directly http://www.mongodb.org/display/DOCS/Ruby+Tutorial
- Keep an eye out on the github commit feed as it's a bit of a moving target still
- http://blog.mongodb.org/
- http://github.com/jnunemaker/mongomapper
- http://groups.google.com/group/mongomapper
- http://railstips.org/ - Author of MongoMapper
- http://railscasts.com/episodes/194-mongodb-and-mongomapper
- http://mongohq.com/ - MongoDB in the cloud
- Mongo3 - visualize your cluster
- http://nosql.mypopescu.com/tagged/mongodb
Summary
No migrations (yes!), storing arrays and hashes as attribute keys (sweet), and inplace updates (ftw). We're not going to use MongoDB to build transactional systems any time soon, but for the majority of web applications it's a perfect fit.
Bit Zesty - Ruby on Rails Development (and MongoDB) UK

