gpt4 book ai didi

ruby-on-rails - 嵌套表单上的 update_attributes 不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 16:57:05 25 4
gpt4 key购买 nike

我有一个嵌套表单并尝试使用 update_attributes 更新它,但它似乎不起作用。我正在使用 Rails 2.3.8

你能帮忙吗?

阿努

添加一些代码

Controller 代码:

update
@app.update_attributes(params[:application])
end

@_参数:

{"authenticity_token"=>"AdSr8o51u7GfnOwLSpEOe5xAPINd7ImxDpuayPk12No=", "_method"=>"put", "action"=>"update", "id"=>"10006", "stype"=>"Save", 
"application"=>{
"contact_attributes"=>{"city"=>"Denver", "address"=>"7000 Drive", "zip"=>"22222", "first_name"=>"Randy"}, "details_attributes"=>{
"2"=>{ "coverage"=>"false", "same_fee"=>"true", "fee_rate"=>"2000", "id"=>"10018", "year_estabilished"=>"2005"}
}}
}

最佳答案

那么,您的模型中是否定义了 accepts_nested_attributes_for?在这里看看:http://apidock.com/rails/ActiveRecord/NestedAttributes/ClassMethods/accepts_nested_attributes_for

关于ruby-on-rails - 嵌套表单上的 update_attributes 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7100528/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com