【问题标题】:The Wicked wizard gem ignores my steps and jumps to request_steps/wicked_finish邪恶的向导 gem 会忽略我的步骤并跳转到 request_steps/wicked_finish
【发布时间】:2013-09-23 14:19:27
【问题描述】:

我正在使用wicked gem 在我点击 RequestStepsController#update 后,我被重定向到 /request_steps/wicked_finish。我不知道为什么。有什么建议么? 如果它按我的预期工作,那么更新对象后的下一步将是 :the_frame,如步骤中所述。

来自日志:

开始为 127.0.0.1 放置“/request_steps/77” RequestStepsController#update 作为 HTML 处理 参数:{"utf8"=>"✓", "authenticity_token"=>"XXX", "request"=>{"background_information"=>"prefilled"}, "commit"=>"C 7"} 重定向到 http://localhost:3000/request_steps/wicked_finish 开始为 127.0.0.1 获取“/request_steps/wicked_finish” RequestStepsController#show as HTML 处理 参数:{"id"=>"wicked_finish"} 完成 404 Not Found in 180ms ActiveRecord::RecordNotFound - 找不到没有 ID 的请求:

这是我的 RequestStepsController

类 RequestStepsController

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|

【问题讨论】:

    标签: ruby ruby-on-rails-4 wicked-gem


    【解决方案1】:

    (免责声明:我没有阅读您的完整问题:))

    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

    【讨论】:

    • 谢谢,Building-Partial-Objects-Step-by-Step Wiki 页面解释了我需要什么。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-11
    • 2015-02-22
    • 1970-01-01
    • 2023-03-18
    • 2017-01-15
    • 1970-01-01
    • 2019-03-16
    相关资源
    最近更新 更多