0

I ran into this very interesting problem which i am trying to resolve since last 3-4 hours, where i am not able to permit unknown nested array in json , its setting to empty array

params=ActionController::Parameters.new({"id"=>21, "tags"=>{"key"=>[["browser", "Chrome 28.0.1500"], ["browser.name", "Chrome"]]}, "nested_key"=>{"key_2"=>"value_2"}})

doing

params.permit(:id, tags: {}, nested_key: {}) 

is giving me nested array as empty("key"=>[]),

#<ActionController::Parameters {"id"=>21, "tags"=>#<ActionController::Parameters {"key"=>[]} permitted: true>, "nested_key"=>#<ActionController::Parameters {"key_2"=>"value_2"} permitted: true>} permitted: true> 

I want all nested elements of array to be permitted since its part of the json. Can anyone help me with this ? Please note that nested keys are dynamic which i will not be aware of while permitting.

Shubham kumar
  • 712
  • 7
  • 12
  • Does this help: https://stackoverflow.com/questions/18349887/rails4-how-to-permit-a-hash-with-dynamic-keys-in-params – engineersmnky Oct 17 '22 at 20:55
  • this will not help @engineersmnky as i want to permit all the keys as it is, but permit every thing for other key including nested json. – Shubham kumar Oct 18 '22 at 06:07

0 Answers0