I allready read this anwer how to permit an array with strong parameters but I cannot figure this situation using params.permit, from a byebug session using rails 4.2:
how can I extract the comments parameters?
(byebug) params
{"comments"=>"[{\"comment\":\"ndjsnjakldnfljkasdbfhjae\",\"date\":\"2017-07-20 17:14:38\"}]", "format"=>:json, "controller"=>"airis/observations", "action"=>"create", "id"=>"13534543543"}
(byebug) params.permit(:id)
[2017-07-20 19:14:43 +0200] [f2b3d7c8-c84a-43a5-b48f-0f634be49dc7] Unpermitted parameters: comments, format
{"id"=>"13534543543"}
(byebug) params.permit(:comments)
[2017-07-20 19:14:43 +0200] [f2b3d7c8-c84a-43a5-b48f-0f634be49dc7] Unpermitted parameters: format, id
{"comments"=>"[{\"comment\":\"ndjsnjakldnfljkasdbfhjae\",\"date\":\"2017-07-20 17:14:38\"}]"}
(byebug) params.permit(comments: [:comment, :date])
[2017-07-20 19:14:43 +0200] [f2b3d7c8-c84a-43a5-b48f-0f634be49dc7] Unpermitted parameters: format, id
{"comments"=>nil}
(byebug) params.permit(:id, comments: [:comment, :date])
[2017-07-20 19:14:43 +0200] [f2b3d7c8-c84a-43a5-b48f-0f634be49dc7] Unpermitted parameter: format
{"id"=>"13534543543", "comments"=>nil}
or even with this:
(byebug) params.permit( :comments => [:comment, :date])
[2017-07-20 19:14:43 +0200] [f2b3d7c8-c84a-43a5-b48f-0f634be49dc7] Unpermitted parameters: format, id
{"comments"=>nil}