2013-09-23 30 views
2

我使用的是wicked gem 在我點擊RequestStepsController#update後,我被重定向到/ request_steps/wicked_finish。我不知道爲什麼。有什麼建議麼? 如果它按照我的預期工作,那麼更新對象後的下一步是:the_frame,如步驟中所述。邪惡的精靈寶石忽略我的步驟並跳轉到request_steps/wicked_finish

從日誌:

 
    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: 

這是我RequestStepsController

類RequestStepsController < ApplicationController的 包括妖獸::嚮導

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 

這是我的表格:

= simple_form_for(@request, url: wizard_path(@request), method: :put, :html => { :class => 'form-inline span8 help_text' }) do |f| 

回答

4

(聲明:我沒有看過你的完整的問題:))

render_wizard方法檢查,如果它可以節省您的@request對象。如果它可以它將進入下一步,並嘗試將其保存在那裏..等等..直到最後一步。

看到這裏的源代碼:https://github.com/schneems/wicked/blob/master/lib/wicked/controller/concerns/render_redirect.rb#L17

要這麼做,你需要確保你的對象不能保存在特定步驟停止它。像這樣描述:https://github.com/schneems/wicked/wiki/Building-Partial-Objects-Step-by-Step

您也可以使用render_step(params[:id])而不是render_wizard

+0

謝謝,建築 - 部分對象 - 分步維基頁面解釋了我需要的內容。 – martins