activeadmin - 覆盖强大的params以发表评论

时间:2017-05-27 17:43:48

标签: ruby-on-rails ruby-on-rails-5 activeadmin

我正在尝试将名为category的属性添加到有效的管理员评论中。我已成功更改评论表单。当我提交评论时,我得到以下内容:

Started POST "/admin/comments" for ::1 at 2017-05-27 08:20:41 -0400
Processing by Admin::CommentsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"vaGGzKnE10Nn/QmIzBk+2K0OqvheX6hPRHlm9F9BJkEL1I6D9YDz+qx1d1ekuuVkIfnqYamXqc5aLJH3TFdF4g==", "active_admin_comment"=>{"resource_type"=>"Person", "resource_id"=>"1203", "body"=>"test comment with category", "category"=>"Adventures"}, "commit"=>"Add Comment"}
  AdminUser Load (1.2ms)  SELECT  "admin_users".* FROM "admin_users" WHERE "admin_users"."id" = $1 ORDER BY "admin_users"."id" ASC LIMIT $2  [["id", 1], ["LIMIT", 1]]
Unpermitted parameter: category

如您所见,我无法保存该类别。我无法弄清楚如何访问活动管理员评论的强大参数。我该怎么做?

1 个答案:

答案 0 :(得分:0)

评论permit_parameters已注册in this DSL。 DSL在资源注释控制器here中动态定义allowed_pa​​rams方法。也许可以使用after_load来更新允许的参数。