Rails 4:允许的参数哈希

时间:2016-09-28 19:54:44

标签: ruby-on-rails-4 parameters

我的参数如下:

{"utf8"=>"✓",
 "authenticity_token"=>"...",
 "consult_stat"=>
    {"0"=>
        {"employee_id"=>"1",
         "consults"=>"7",
         "signed"=>"8"},
     "1"=>
        {"employee_id"=>"2",
         "consults"=>"5",
         "signed"=>"6"}
     },
 "commit"=>"Submit Consultation Stats"}

如何使用动态密钥允许嵌套哈希?

1 个答案:

答案 0 :(得分:0)

这很简单,你可以实现它

params.require(:consult_stat).permit(:employee_id,:consults,:signed)