Using MongoDB with Rails
NoSQL databases have gone from being a curiosity to being the backend of enterprise web apps. Likewise, Rails has also matured enough to be adopted by large organizations while still being a startup favorite. Rails grew up with SQL so implementing a NoSQL database may seem to be unconventional. This guide will help any user be able to easily set up one of the most popular NoSQL databases, MongoDB.
When you set up your initial Rails project make sure to skip active record.
rails new my_app --skip-active-record
Active record uses migrations to control your database, which won’t be needed with MongoDB.
Use Mongoid. Mongoid is a ODM (object document mapper) framework for Mongo in Ruby. It will make the rest of the process much simpler and will help you manage your database without active record.
Mongoid is wrapped up in a gem which makes installation a breeze.
Continue reading →