Created
January 31, 2017 19:06
-
-
Save macfanatic/fb53c0f8c49138b617fab34996efe184 to your computer and use it in GitHub Desktop.
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
# app/models/post.rb | |
class Post < ActiveRecord::Base | |
attr_accessible :body, :status, :title | |
validates :title, presence: true, uniqueness: true | |
validates :body, presence: true | |
DRAFT = 'draft' | |
REVIEWED = 'reviewed' | |
PUBLISHED = 'published' | |
state_machine :status, initial: DRAFT do | |
event :peer_review do | |
transition DRAFT => REVIEWED | |
end | |
event :publish do | |
transition REVIEWED => PUBLISHED | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment