基于 Ryan Bates嵌套模型表单教程中的此功能,当我提交表单时,我收到了一组已提交的数据:
{
"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