Created
February 5, 2011 00:49
-
-
Save edave/812076 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
include AASM | |
aasm_column :current_state | |
aasm_state :active | |
aasm_state :free_trial | |
aasm_state :disabled #this is for accounts that have exceed free trial and have not paid | |
aasm_state :payment_failed | |
#aasm_state :free_acct | |
aasm_event :payment_succeeded do | |
transitions :to => :active, :from => [:free_trial, :disabled, :payment_failed] # when a payment succeeds, the account is active | |
end | |
aasm_event :disable do | |
transitions :to => :disabled, :from => [:free_trial, :active, :payment_failed] # when an account is overdue, or at the end of a free trial, it should be disabled | |
end | |
aasm_event :payment_failure do | |
transitions :to => :payment_failed, :from [:active, :disabled] # when an account tries to make a payment and it fails, send it into payment failure | |
transitions :to => :free_trial, :from [:free_trial] # when an account tries to make a payment during the free period, and it fails, just put them back into the free period | |
# should add a conditional check to make sure that this rule doesn't work if they've exceeded their free trial period | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment