Created
October 17, 2017 20:54
-
-
Save negabaro/a461a02eb6f32c25f5845a0f861ed1ac to your computer and use it in GitHub Desktop.
Rails AASM model example
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
include AASM | |
aasm do | |
state :draft, :initial => true | |
state :published | |
#event :publish, before: ->{ self.published_at = Time.now } do | |
event :publish do | |
transitions :from => :draft, :to => :published | |
end | |
event :draft do | |
transitions :from => :published, :to => :draft | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment