Skip to content

Instantly share code, notes, and snippets.

@waynerobinson
Created April 6, 2011 01:48
Show Gist options
  • Save waynerobinson/904986 to your computer and use it in GitHub Desktop.
Save waynerobinson/904986 to your computer and use it in GitHub Desktop.
Address Object
class Address < ActiveRecord::Base
ADDRESS_TYPES = %w(Office Postal Shipping)
default_scope order('created_at DESC')
scope :active, where(active: true)
validates_inclusion_of :address_type, in: ADDRESS_TYPES, message: "must be one of #{ADDRESS_TYPES.to_sentence(last_word_connector: ' or ')}"
belongs_to :source, polymorphic: true
belongs_to :updated_by, class_name: 'User', foreign_key: 'updated_by_user_id'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment