Skip to content

Instantly share code, notes, and snippets.

@EdgarOrtegaRamirez
Forked from rainchen/photo.rb
Created September 17, 2013 17:26
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 EdgarOrtegaRamirez/6597598 to your computer and use it in GitHub Desktop.
Save EdgarOrtegaRamirez/6597598 to your computer and use it in GitHub Desktop.
class Photo < ActiveRecord::Base
module Statues
QUEUED = 'queued'
NEW = 'new'
def self.values
constants.map(&method(:const_get))
end
# you can define more special methods as you wanted for Statues
end
validates :status, inclusion: {in: Statues.values }
def change_status
self.status = Statues::NEW
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment