Skip to content

Instantly share code, notes, and snippets.

@danielb2
Created October 18, 2010 13:31
Show Gist options
  • Save danielb2/632223 to your computer and use it in GitHub Desktop.
Save danielb2/632223 to your computer and use it in GitHub Desktop.
#!/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