Skip to content

Instantly share code, notes, and snippets.

@seebq
Forked from anonymous/gist:670982
Created November 10, 2010 15:24
Show Gist options
  • Save seebq/670985 to your computer and use it in GitHub Desktop.
Save seebq/670985 to your computer and use it in GitHub Desktop.
class Widget < ActiveRecord::Base
AMERICAN_COLORS = %w(red white blue)
# /(red|white|blue)/i
validate :must_be_american
def must_be_american
unless AMERICAN_COLORS.include?(self.color.downcase)
errors.add(:color, " has to be american (#{AMERICAN_COLORS.to_sentence}, buddy....")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment