Skip to content

Instantly share code, notes, and snippets.

@priyaaank
Created October 21, 2012 08:39
Show Gist options
  • Save priyaaank/3926360 to your computer and use it in GitHub Desktop.
Save priyaaank/3926360 to your computer and use it in GitHub Desktop.
Models for Modular API with Grape and Rails
class ContactInfo
include Mongoid::Document
field :address_line, :type => String
field :city, :type => String
field :country, :type => String
field :zipcode, :type => String
field :state, :type => String
embeds_many :phone_numbers
end
class PhoneNumber
include Mongoid::Document
field :country_code, :type => String
field :area_code, :type => String
field :number, :type => String
def formatted_number
["+"+country_code,area_code,number].join("-")
end
end
class User
include Mongoid::Document
field :first_name, :type => String
field :last_name, :type => String
field :email, :type => String
field :username, :type => String
embeds_one :contact_info
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment