Created
April 6, 2011 01:48
-
-
Save waynerobinson/904986 to your computer and use it in GitHub Desktop.
Address Object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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