You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Benoit Tigeot edited this page Feb 10, 2021
·
6 revisions
I created a helper method to quickly show a step count to the end user. The method feels a bit dirty (I think some Rubyists here might be able to clean this up) but it gets the job done. The objective of this code is to output a dynamic progress counter ("4/13") so it can be used in a context like "Question Set 4/13".
Put this method in your ...StepsHelper.rb file
defstep_progress# get current step's relative positionstep_index=wizard_steps.each_with_index.select{ |i,idx| i =~ /#{step}/}step_index_results=step_index.map!{ |i| i[1]}# nb// adjust to account for array starting index at 0current_step_position=step_index_results.first + 1# get total number of steps# nb// adjust to account for array starting index at 0total_step_count=wizard_steps.size + 1"#{current_step_position}/#{total_step_count}"end