Skip to content

Instantly share code, notes, and snippets.

@davejachimiak
Created June 9, 2012 16:50
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 davejachimiak/2901758 to your computer and use it in GitHub Desktop.
Save davejachimiak/2901758 to your computer and use it in GitHub Desktop.
:inclusion validator
class Resource < ActiveRecord::Base
module Types
ACTIVE = 'active'
CANCELLED = 'cancelled'
CEASED = 'ceased'
DITCHED = 'ditched'
MEDIA = 'media'
ONE_TIME = 'one time'
ARCHIVED = 'archived'
end
RESOURCE_TYPES = [Types::ACTIVE, Types::CANCELLED, Types::CEASED, Types::DITCHED,
Types::MEDIA, Types::ONE_TIME, Types::ARCHIVED]
validates :resource_type, :inclusion => { :in => RESOURCE_TYPES,
:message => "%{value} is not a valid resource type value" }
...
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment