Skip to content

Instantly share code, notes, and snippets.

@iwan
Created October 11, 2013 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iwan/6931191 to your computer and use it in GitHub Desktop.
Save iwan/6931191 to your computer and use it in GitHub Desktop.
How to use Mongodb with Mongoid gem in Ruby
# file: mongoid.yml
default:
sessions:
production:
database: foobar
hosts:
- localhost:27017
# file: mongoid.rb
require 'mongoid'
Mongoid.load!("mongoid.yml", :production)
class Person
include Mongoid::Document
field :first_name, type: String
field :last_name, type: String
end
p = Person.create(first_name: "Jack", last_name: "Bauer")
puts p.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment