Skip to content

Instantly share code, notes, and snippets.

@ni-ka
Created May 15, 2012 08:52
Show Gist options
  • Save ni-ka/2700151 to your computer and use it in GitHub Desktop.
Save ni-ka/2700151 to your computer and use it in GitHub Desktop.
class User
include MongoMapper::Document
key :uid, String, :required => true, :unique => true
one :profile
end
class Profile
include MongoMapper::EmbeddedDocument
embedded_in :user
many :industries
end
class Expertise
include MongoMapper::EmbeddedDocument
key :expertise, String, :required => true
key :proficiency, Fixnum
end
class Industry < Expertise
validates :expertise, :unique_expertise => true,
:inclusion => { :in => Profile::INDUSTRIES }
validates :proficiency, :inclusion => { :in => 0..4 },
:presence => true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment