Skip to content

Instantly share code, notes, and snippets.

@leastbad
Created December 3, 2020 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leastbad/fd33e2918eb37fcd6c30e593f20e7a1f to your computer and use it in GitHub Desktop.
Save leastbad/fd33e2918eb37fcd6c30e593f20e7a1f to your computer and use it in GitHub Desktop.
Julian's multi-step validations state machine
aasm do
state :invited, initial: true
state :identified
state :details_added
state :bank_details_added
state :completed
event :identify do
transitions from: :invited, to: :identified
end
event :add_details do
transitions from: :identified, to: :details_added
end
event :add_bank_details do
transitions from: :details_added, to: :bank_details_added
end
event :complete do
transitions from: :bank_details_added, to: :completed
end
end
validates :company_name, :address, :country, :zip, :city,
:trade_certificate, presence: true, on: :add_details
validates :terms_of_service, acceptance: true, on: :complete
= render 'devise/registrations/activation/step_1_identification' if @partner.invited?
= render 'devise/registrations/activation/step_2_details' if @partner.identified?
= render 'devise/registrations/activation/step_3_bank_account' if @partner.details_added?
= render 'devise/registrations/activation/step_4_acceptance' if @partner.bank_details_added?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment