[英]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.