Skip to content

Instantly share code, notes, and snippets.

@jfryman
Created September 14, 2012 20:56
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 jfryman/250f6c7d358855e0242f to your computer and use it in GitHub Desktop.
Save jfryman/250f6c7d358855e0242f to your computer and use it in GitHub Desktop.
class XXX < ActiveRecord::Base
CONTACT_METHODS = [:snail_mail, :carrier_pigeon, :telegram]
attr_reader :requested_mode
enum :fulfilled_mode, CONTACT_METHODS
enum :requested_mode, CONTACT_METHODS
# Associations
belongs_to :assignee, :class_name => 'User'
belongs_to :client, :class_name => 'User'
# Validations
validates_presence_of :name
validates_presence_of :description
validates_presence_of :requested_mode
validates_inclusion_of :fulfilled_mode, :in => CONTACT_METHODS, :message => "Fulfilled mode must be one of the following: #{CONTACT_METHODS.join(',')}"
validates_inclusion_of :requested_mode, :in => CONTACT_METHODS, :message => "Requested mode must be one of the following: #{CONTACT_METHODS.join(',')}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment