Skip to content

Instantly share code, notes, and snippets.

@alex-tan
Created June 12, 2012 07:12
Show Gist options
  • Save alex-tan/2915822 to your computer and use it in GitHub Desktop.
Save alex-tan/2915822 to your computer and use it in GitHub Desktop.
class Record < ActiveRecord::Base
state_machine :state, initial: :state_one do
state :state_one,
:state_two
before_transition to: :state_two,
do: :state_two_event
end
state_machine :public_state, attribute: :state do
event(:move_to_state_two) { transition :state_one => :state_two }
end
def state_two_event
true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment