Skip to content

Instantly share code, notes, and snippets.

@joelhooks
Created October 6, 2016 23:34
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 joelhooks/9ed9a326fc0aa40335adacf20910d5bb to your computer and use it in GitHub Desktop.
Save joelhooks/9ed9a326fc0aa40335adacf20910d5bb to your computer and use it in GitHub Desktop.
aasm :column => :state do
state :proposed, :initial => true
state :cancelled
state :accepted
state :claimed
state :submitted
state :rejected
state :updated
state :approved
state :published
state :flagged
state :revised
state :retired
event :cancel do
transitions :from => [:accepted, :claimed, :submitted, :proposed, :updated], :to => :cancelled
end
event :accept do
transitions :from => :proposed, :to => :accepted
end
event :claim do
transitions :from => :accepted, :to => :claimed
end
event :submit do
transitions :from => :claimed, :to => :submitted
end
event :reject do
transitions :from => [:submitted, :updated], :to => :rejected
end
event :update do
transitions :from => :rejected, :to => :updated
end
event :approve do
transitions :from => [:submitted, :updated], :to => :approved
end
event :publish do
transitions :from => :revised, :to => :published
transitions :from => :approved, :to => :published
end
event :flag do
transitions :from => :published, :to => :flagged
end
event :revise do
transitions :from => :flagged, :to => :revised
end
event :retire do
transitions :from => [:published, :flagged], :to => :retired
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment