From c490523412724a4a81464ce42de0f0ffa6821223 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Mon, 13 Nov 2017 15:49:08 +0800 Subject: [PATCH] Start step bugfix --- lib/wizard.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/wizard.rb b/lib/wizard.rb index 2e32d38a..5946a355 100644 --- a/lib/wizard.rb +++ b/lib/wizard.rb @@ -51,13 +51,14 @@ class CustomWizard::Wizard end def start - if unfinished? - step_id = ::UserHistory.where( + if unfinished? && last_completed_step = ::UserHistory.where( acting_user_id: @user.id, action: ::UserHistory.actions[:custom_wizard_step], context: @id, subject: @steps.map(&:id) - ).order("created_at").last.subject + ).order("created_at").last + + step_id = last_completed_step.subject last_index = @steps.index { |s| s.id == step_id } @steps[last_index + 1] else