This plugin provides an ActiveRecord connection adapter for Mongo (www.mongodb.org/).
This plugin relies on the “mongo” Ruby Gem, which can be found at github.com/mongodb/mongo-ruby-driver. See the README file there for installation instructions.
After installing this plugin, you will need a db/schema.rb file and a database.yml file. See below for instructions.
As noted above, this plugin requires the “mongo” Ruby Gem, version 0.5.4 or higher.
To add this plugin to your Rails app, move (or link) this directory into your Rails app’s vendor/plugins directory and name it mongo_record. In other words, this README.rdoc file should be
RAILS_ROOT/vendor/plugins/mongo_record/README.rdoc
ActiveRecord requires a schema, but Mongo is a schema-free database. This means that you have to supply this plugin with a schema for your Mongo database that ActiveRecord can use.
This plugin reads the file named by ENV or, if that is not defined, db/schema.rb to get the database schema the application wants to use.
In case you need to hand-generate a schema file (for example, you don’t have a db/schema.rb file generated by “rake db:schema:dump”, here is a small sample.
ActiveRecord::Schema.define(:version => 0) do create_table "students", :force => true do |t| t.column "name", :string, :null => false end create_table "addresses", :force => true do |t| t.column "student_id", :integer, :null => false t.column "street", :string t.column "city", :string t.column "state", :string t.column "postal_code", :string end add_index "addresses", ["student_id"], :name => "fk_addresses_students" create_table "courses", :force => true do |t| t.column "name", :string end create_table "scores", :force => true do |t| t.column "student_id", :integer, :null => false t.column "course_id", :integer, :null => false t.column "grade", :float, :null => false end end
development: adapter: mongo database: foo_development test: adapter: mongo database: foo_test production: adapter: mongo database: foo_production
If you wish, you can use a Mongo capped collection for Rails log messages. To do so, edit the file init.rb and uncomment the code following the comment that says “Uncomment the following to log to Mongo using a capped collection.” See MongoRecord::LogDevice for details.
If enabled, log messages are sent to the capped collection named rails_log_{RAILS_ENV}.
Copyright © 2009 10gen Inc.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License, version 3, as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <www.gnu.org/licenses/>.