Update doesn't go to next step
noff opened this issue · 3 comments
Rails 5.2.3
Wicked gem wicked (1.3.4)
Controller:
class WizardStudentController < ApplicationController
include Wicked::Wizard
steps :personal, :avatar, :socials, :current_work, :debts, :insurance, :motivation, :ambitions, :forecast, :education, :documents
def show
@user = current_user
redirect_to dashboard_path unless @user.applicant?
case step
when :personal
when :avatar
when :socials
when :current_work
end
render_wizard
end
def update
@user = current_user
redirect_to dashboard_path unless @user.applicant?
case step
when :personal
@user.update params[:user].permit(:first_name, :last_name)
when :avatar
when :socials
when :current_work
end
render_wizard
end
end
View personal.slim
:
.container
.row
.col-md-8
= simple_form_for @user, url: wizard_path, method: :put do |f|
= f.input :first_name
= f.input :last_name
= f.submit t('active_admin.next'), class: 'btn btn-primary'
.col-md-4
div Personal info
When I click form button, user info is saved to database, but I stay on the same step - personal
.
According to README:
We're passing render_wizard our @user object here. If you pass an object into render_wizard it will show the next step if the object saves or re-render the previous view if it does not save.
So it re-render the previous step even if it saves the model properly
So it re-render the previous step even if it saves the model properly?
I'm not totally sure. Reading the code I think that's what's happening
wicked/lib/wicked/controller/concerns/render_redirect.rb
Lines 4 to 29 in a1e465d
try render_wizard @user
? You don't provide a record.
Is this resolved? Still an issue? If so can someone give me a reproduction application? https://www.codetriage.com/example_app