Skip to content

Instantly share code, notes, and snippets.

@softwaregravy
Created August 7, 2011 03:25
Show Gist options
  • Save softwaregravy/1130024 to your computer and use it in GitHub Desktop.
Save softwaregravy/1130024 to your computer and use it in GitHub Desktop.
State machine driving registrations
state_machine do
state :email, :exit => lambda {|reg| reg.errors.clear }
state :age, :exit => lambda {|reg| reg.errors.clear }
state :complete, :enter => :register_user
event :next do
transitions :from => :email, :to => :age, :guard => :guard_to_age
transitions :from => :age, :to => :complete, :guard => :guard_to_complete
# do not allow complete => complete
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment