Skip to content

Show Current Wizard Progress to User

David Corking edited this page Feb 8, 2021 · 6 revisions
  1. your_wizard_controller.rb:
  before_action :set_progress, only: [:show]
  private
    def set_progress
      if wizard_steps.any? && wizard_steps.index(step).present?
        @progress = ((wizard_steps.index(step) + 1).to_d / wizard_steps.count.to_d) * 100
      else
        @progress = 0
      end
    end
  1. your_wizard_view.html.haml: (using bootstrap + haml)
  .progress
    .progress-bar{style: "width: #{@progress}%"}