Created
September 20, 2012 15:36
-
-
Save k2052/3756650 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
require 'mongo' | |
require 'mongo_mapper' | |
MongoMapper.connection = Mongo::Connection.new('localhost', nil) | |
MongoMapper.database = 'sandbox_poly' | |
class Commentable | |
include MongoMapper::Document | |
many :comments, :as => :commentable | |
end | |
class Article < Commentable | |
key :title | |
end | |
class Product < Commentable | |
key :sku | |
end | |
class Comment | |
include MongoMapper::Document | |
key :text | |
belongs_to :commentable | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment