Skip to content

Instantly share code, notes, and snippets.

@lorennorman
Created January 7, 2010 18:51
Show Gist options
  • Save lorennorman/271454 to your computer and use it in GitHub Desktop.
Save lorennorman/271454 to your computer and use it in GitHub Desktop.
# Stolen from: http://railstips.org/blog/archives/2009/10/09/more-mongomapper-awesomeness/
class User
include MongoMapper::Document
many :posts
end
class Post
include MongoMapper::Document
key :user_id, String
key :title, String
end
user = User.create
user.posts.create(:title => 'Foo')
# would return post we just created
user.posts.find_by_title('Foo')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment