Last active
December 25, 2015 09:09
-
-
Save squidge/6951574 to your computer and use it in GitHub Desktop.
Ruby and Mongoid
This file contains hidden or 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
require 'mongoid' | |
Mongoid.load!("mongoid.yml", environment = "development") | |
class Artist | |
include Mongoid::Document | |
field :name, type: String | |
embeds_many :instruments | |
end | |
class Instrument | |
include Mongoid::Document | |
field :name, type: String | |
embedded_in :artist | |
end | |
syd = Artist.where(name: "Logsie").first | |
#syd = Artist.create(name: 'Logsie') | |
syd.instruments.create(name: "Drum") | |
#syd.with(database: "bands", session: "backup").save! |
This file contains hidden or 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
development: | |
sessions: | |
default: | |
database: test_dev | |
hosts: | |
- localhost:27017 | |
options: | |
#read: strong |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment