0
我有一張發票,其中有許多發票行。在編輯時當點擊刪除按鈕作爲發票行時,我使用javascript將隱藏的_destroy字段設置爲值1。提交時應該刪除這些項目。它正在工作,但它今天隨機停止。發送_destroy參數不刪除關聯
以下是發送的參數:
Parameters: {
"recycler_invoice"=>{
"number"=>"IT10059",
"customer_id"=>"1",
"date_entered"=>"10/04/2013",
"gold_spot_price_paid"=>"1248.12",
"silver_spot_price_paid"=>"22.46",
"platinum_spot_price_paid"=>"1206.13",
"refine_fee_percentage"=>"5.0",
"consulting_fee_percentage"=>"3.0",
"verify_fee_percentage"=>"2.0",
"recycler_invoice_lines_attributes"=>{
"0"=>{"denomination_id"=>"11", "quantity"=>"315.767", "_destroy"=>"false", "id"=>"1023"},
"1"=>{"denomination_id"=>"7", "quantity"=>"78.466", "_destroy"=>"false", "id"=>"1024"},
"2"=>{"denomination_id"=>"1", "quantity"=>"1.174", "_destroy"=>"false", "id"=>"1025"},
"3"=>{"denomination_id"=>"2", "quantity"=>"7.46", "_destroy"=>"false", "id"=>"1026"},
"4"=>{"denomination_id"=>"9", "quantity"=>"28.909", "_destroy"=>"false", "id"=>"1027"},
"5"=>{"denomination_id"=>"10", "quantity"=>"9.629", "_destroy"=>"false", "id"=>"1028"},
"6"=>{"denomination_id"=>"13", "quantity"=>"19.77", "_destroy"=>"false", "id"=>"1029"},
"7"=>{"denomination_id"=>"14", "quantity"=>"5.83", "_destroy"=>"false", "id"=>"1030"},
"8"=>{"denomination_id"=>"22", "quantity"=>"240.37", "_destroy"=>"1", "id"=>"1031"}}},
"commit"=>"Submit",
"id"=>"9"}
正如你可以看到,我想刪除的線具有1
_destroy這裏是我的更新代碼...很簡單:
def update
@recycler_invoice = RecyclerInvoice.find(params[:id])
respond_to do |format|
if @recycler_invoice.update_attributes(params[:recycler_invoice])
format.html { redirect_to @recycler_invoice, notice: 'Recycler invoice was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @recycler_invoice.errors, status: :unprocessable_entity }
end
end
end
你是對的!我想我被拋棄了,因爲我認爲它的工作時間最長。我在想,也許它不是,我現在才注意到......非常感謝你! – 2013-04-10 22:22:58