Skip to content

Instantly share code, notes, and snippets.

@obrie
Created June 14, 2010 01:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obrie/437137 to your computer and use it in GitHub Desktop.
Save obrie/437137 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
state_machine :initial => :pending do
# Event to call each time user proceeds to the next step
event :proceed do
transition :pending => :personal_info_registered
transition :personal_info_registered => :payment_info_registered
transition :payment_info_registered => :activated
end
# Attributes that must be present in at least Step 1
state :personal_info_registered, :payment_info_registered, :activated do
validates_presence_of :first_name, :last_name, :email
end
# Attributes that must be present in at least Step 2
state :payment_info_registered, :activated do
validates_presence_of :paypal_email
end
# Attributes that must be present in Step 3
state :activated do
validates_presence_of :password
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment