Created
October 18, 2010 13:31
-
-
Save danielb2/632223 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
gem 'bson_ext', '1.0.4' | |
gem "mongoid", '2.0.0.beta.19' | |
require 'mongoid' | |
require 'fabrication' | |
Mongoid.configure do |config| | |
name = "test" | |
host = "localhost" | |
config.master = Mongo::Connection.new.db(name) | |
end | |
class User | |
include Mongoid::Document | |
field :name | |
end | |
class Feed | |
include Mongoid::Document | |
embeds_many :posts | |
end | |
class Post; | |
include Mongoid::Document | |
embedded_in :feed, :inverse_of => :post | |
end | |
f = Feed.create name: 'test' | |
f.posts.create title: 'foo' | |
feed = Feed.last | |
p feed.name | |
p feed.posts.last.title |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment