我有一个嵌套表单并尝试使用 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/