Created
January 7, 2010 18:51
-
-
Save lorennorman/271454 to your computer and use it in GitHub Desktop.
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
# 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