Created
October 11, 2013 08:00
-
-
Save iwan/6931191 to your computer and use it in GitHub Desktop.
How to use Mongodb with Mongoid gem in Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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