基于Ryan Bates Nested Model Form教程的这个功能,当我提交表单时,我已经提交了这组数据:
{
"authenticity_token"=>"mdohADjieoqUwOwUK/H52TAiH5HdFYQtTbTuMJtDJE8=",
"utf8"=>"✓",
"id"=>"92",
"survey"=>
{
"questions_attributes"=>
{
"1299616889104"=>
{
"display_type"=>"",
"text"=>"",
"other"=>"0",
"display_order"=>"0",
"answer_choices"=>"",
"item_type"=>"multiple_choice"
},
"new_questions"=>
{
"display_type"=>"compare",
"pick"=>"one",
"text"=>"",
"other"=>"0",
"display_order"=>"0",
"answer_choices"=>"",
"item_type"=>"compare"
}
},
"id"=>"92"
}
}
我需要弄清楚如何做的是忽略new_questions
部分。我知道您可以将reject_if
添加到accepts_nested_attributes_for
,但是隐藏的字段已包含并预先填充了数据,因此我无法根据空字段进行忽略。
那么如何在我的示例数据中忽略new_questions
?
我正在运行Rails 3.0.3