1

I am trying to add an attribute called category to an active admin comment. I have successfully changed the comment form. When I submit the comment, I get the following:

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

As you can see, I can't save the category. I can't figure out how to access the strong params of an active admin comment. How do I do that?

Philip7899
  • 4,599
  • 4
  • 55
  • 114
  • My question is about how to access the controller code when using the activeadmin gem. It does the controller stuff behind the scenes - i need to figure out how to access it. – Philip7899 May 27 '17 at 17:49
  • Ohh, have you read [this](https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md)? You can set your own attributes in strong params. – Gerry May 27 '17 at 17:54
  • Thanks, but thats for an active admin resource. This is not a resource - comments come included in activeadmin and their code is hidden somewhere in the gem – Philip7899 May 27 '17 at 17:59

1 Answers1

0

The comment permit_parameters are registered in this DSL. The DSL dynamically defines a permitted_params method in the resource comments controller here. Perhaps it is possible to use after_load to update the permitted parameters.

Piers C
  • 2,880
  • 1
  • 23
  • 29