Skip to content

Instantly share code, notes, and snippets.

@jszmajda
Created February 12, 2010 20:12
Show Gist options
  • Save jszmajda/302930 to your computer and use it in GitHub Desktop.
Save jszmajda/302930 to your computer and use it in GitHub Desktop.
class Car
include MongoMapper::Document
key :make, String
key :_type, String
end
class Honda < Car
key :honda_thing, String
end
class Toyota < Car
key :recalled, Boolean
end
# script/console:
# >> Car.all
# => [#<Honda _id: 4b75b5d7844de47805000001, _type: "Honda", recalled: nil, make: nil, honda_thing: "honda!">, #<Toyota _id: 4b75b5e0844de47805000002, _type: "Toyota", recalled: false, make: nil, honda_thing: nil>]
# mongo:
# > db.cars.find();
# { "_id" : ObjectId("4b75b5d7844de47805000001"), "_type" : "Honda", "make" : null, "recalled" : null, "honda_thing" : "honda!" }
# { "_id" : ObjectId("4b75b5e0844de47805000002"), "_type" : "Toyota", "make" : null, "recalled" : false, "honda_thing" : null }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment