Skip to content

Instantly share code, notes, and snippets.

@negabaro
Created October 17, 2017 20:54
Show Gist options
  • Save negabaro/a461a02eb6f32c25f5845a0f861ed1ac to your computer and use it in GitHub Desktop.
Save negabaro/a461a02eb6f32c25f5845a0f861ed1ac to your computer and use it in GitHub Desktop.
Rails AASM model example
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