Thursday, 3 November 2011

supporting links for mongoDB

Getting started:

        http://www.mongodb.org/display/DOCS/MongoDB+Data+Modeling+and+Rails
        http://www.mongodb.org/display/DOCS/Rails+3+-+Getting+Started

For mongo shell:
     
       http://www.mongodb.org/display/DOCS/Overview+-+The+MongoDB+Interactive+Shell
       

Getting MongoDB and Devise to play well on Rails 3


Link:

http://blog.mattgauger.com/getting-mongodb-and-devise-to-play-together-o

Wednesday, 2 November 2011

Rails application using mongomapper (mongoDB)


1) Edit Gemfile, located in the Rails root directory. By default, our Gemfile will only load Rails:


                      require 'mongo'

         gem "mongo_mapper"
         gem "bson_ext"

2) Once you've configured your Gemfile, run the bundle installer:
          bundle install

3) Last item is to create an initializer to connect to MongoDB. Create a Ruby file in config/initializers.       You can give it any name you want; here we'll call it config/initializers/mongo.rb:

 sudo: 
MongoMapper.connection = Mongo::Connection.new('localhost', 27017)
   MongoMapper.database = "#myapp-#{Rails.env}"

   if defined?(PhusionPassenger)
       PhusionPassenger.on_event(:starting_worker_process) do |forked|
       MongoMapper.connection.connect if forked
     end
   end
4) Create a model with mongomapper
 Ex:
 class User 
  include MongoMapper::Document
  
   key :name,  String
   key :email, String
  
   validates_presence_of :name, :email 
  end
6)Generate the controller and view for the User model..