Skip to content

Instantly share code, notes, and snippets.

@PDegenPortnoy
Created September 11, 2013 14:46
Show Gist options
  • Save PDegenPortnoy/6524671 to your computer and use it in GitHub Desktop.
Save PDegenPortnoy/6524671 to your computer and use it in GitHub Desktop.
Acts As State Machine with Successful Callback structures
class Tester < ActiveRecord::Base
include AASM
aasm_initial_state :inactive
aasm_state :inactive
aasm_state :active,
:after_enter => :after_active_state
aasm_event :activate,
:after => :after_event do
transitions :to => :active,
:from => [:inactive]
end
aasm_event :pause do
transitions :to => :inactive,
:from => [:active]
end
def after_event
logger.debug("** after_event ")
end
def after_active_state
logger.debug("** after_active_state")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment