Skip to content

Show Current Wizard Progress to User

yashm edited this page May 3, 2020 · 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 2. your_wizard_view.html.haml: (using bootstrap + haml)

.progress .progress-bar{style: "width: #{@progress}%"}