繁体   English   中英

邪恶宝石的轨道。 数据不会更新

[英]Rails with Wicked gem. Data will not update

我正在使用Wicked gem在多个步骤中创建对象。 在我意识到数据没有保存之前,一切似乎都工作正常。 我注意到,每当表单构建器中出现url: wizard_path时,它都不会保存。 如果不存在该数据,则无论我在哪一步,数据都可以很好地保存。 这是我的对象生成器控制器如下所示:

class Bids::BuildController < ApplicationController
  include Wicked::Wizard

  steps :intro, :problems, :solutions, :pricing

  def show
    @bid = Bid.find(params[:bid_id])
    render_wizard
  end

  def create
    @bid = Bid.new(bid_params)
    redirect_to wizard_path(steps.first, :bid_id => @bid.id)
  end

  def update
    @bid = Bid.find(params[:bid_id])
    params[:bid][:status] = 'active' if step == steps.last
    @bid.attributes = params[:bid].permit(:bid_attribute)
    render_wizard @bid
  end

  # GET /bids/new
  def new
    @bid = Bid.new
    redirect_to wizard_path(steps.first, :bid_id => @bid.id)
  end

end

您在评论中提到您正在允许出价控制器中的参数。 将它们添加到您的构建控制器。 由于要在此控制器中构建对象,因此它需要有权访问允许的参数。

加:

def build_params
  params.require(:bid).permit(:param_1,:param_2,:param_3,:etc)
end

到您的bids/build_controller.rb

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM