Skip to content

Instantly share code, notes, and snippets.

@PDegenPortnoy
Created September 11, 2013 14:44
Show Gist options
  • Save PDegenPortnoy/6524642 to your computer and use it in GitHub Desktop.
Save PDegenPortnoy/6524642 to your computer and use it in GitHub Desktop.
Acts As State Machine (AASM) with callback sample code that was initial, non-functioning, implementation
class Tester < ActiveRecord::Base
include AASM
aasm_initial_state :inactive
aasm_state :inactive
aasm_state :active,
:after_enter => :after_active_state
aasm_event :activate do
transitions :to => :active,
:from => [:inactive],
:after => :after_event
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