Created
June 14, 2010 01:00
-
-
Save obrie/437137 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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