Created
June 9, 2012 16:50
-
-
Save davejachimiak/2901758 to your computer and use it in GitHub Desktop.
:inclusion validator
This file contains 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 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