I'm using the wicked gem After I hit RequestStepsController#update, I'm being redirected to /request_steps/wicked_finish. I have no idea why. Any suggestions? If it worked as I expected it to, then the next step after updating the object would be :the_frame, as described in steps.
From the log:
Started PUT "/request_steps/77" for 127.0.0.1 Processing by RequestStepsController#update as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"XXX", "request"=>{"background_information"=>"prefilled"}, "commit"=>"C 7"} Redirected to http://localhost:3000/request_steps/wicked_finish Started GET "/request_steps/wicked_finish" for 127.0.0.1 Processing by RequestStepsController#show as HTML Parameters: {"id"=>"wicked_finish"} Completed 404 Not Found in 180ms ActiveRecord::RecordNotFound - Couldn't find Request without an ID:
This is my RequestStepsController
class RequestStepsController < ApplicationController include Wicked::Wizard
steps :background_information,
:no_list_what_can_go_wrong,
:the_frame,
:select_group
def show
@request = Request.find(params[:request])
render_wizard
end
def update
@request = Request.find(params[:id])
@request.update_attributes(request_params)
render_wizard @request
end
def request_params
params.require(:request).permit(:title, :description, :goal,
:request_group_id,
:repository_url,
:background_information
)
end
end
This is my form:
= simple_form_for(@request, url: wizard_path(@request), method: :put, :html => { :class => 'form-inline span8 help_text' }) do |f|
(disclaimer: I did not read your complete question :))
The render_wizard
method checks if it can save your @request
object. If it can it will go to the next step and try to save it there.. and so on.. until the last step.
See the source code here: https://github.com/schneems/wicked/blob/master/lib/wicked/controller/concerns/render_redirect.rb#L17
To stop it from doing so you need to make sure your object can't be saved in the particular step. Something like described here: https://github.com/schneems/wicked/wiki/Building-Partial-Objects-Step-by-Step
You could also use render_step(params[:id])
instead of render_wizard
.