Skip to content

Instantly share code, notes, and snippets.

@dob
Created May 31, 2011 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dob/1001054 to your computer and use it in GitHub Desktop.
Save dob/1001054 to your computer and use it in GitHub Desktop.
Migrate to MongoDB sample namespaced Mongoid Models
module MongoHP
class HPObject
include Mongoid::Document
include Mongoid::Timestamps
store_in :hp_objects
field :object_type, :type => String
field :tags, :type => Array
...
# Embeds
embeds_many :images, :as => :photo_owner, :class_name => "MongoHP::Image"
embeds_many :locations, :class_name => "MongoHP::Location"
...
end
class Location
include Mongoid::Document
include Mongoid::Timestamps
embedded_in :hp_object, :class_name => "MongoHP::HPObject"
end
class Image
...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment