Reputation: 119
I have a check_box_tag that returns me a permission object that I can't seem to permit. I have checked on StackOverflow and tried a few things but since I am new to coding and params I can't get to make it work.
The params look like this:
"product_builder_permissions"=>[{"1"=>["1"], "2"=>["1"], "6"=>["42", "59"]}]
with the key of the nested hash being the id of the product builder and the values in the array the object id to which those builders have access to.
If I change a bit my HTML and get one key for each builder, I am able to whitelist with something such as params.permit(
product_builder_permissions1: [])
params.permit(
product_builder_permissions1: [])
etc.
which is inefficient.
I am trying to work with something like params.permit(product_builder_permissions:[0])
I only whitelist the key and value at the first level but not what's nested since I get
{"product_builder_permissions"=>[{}]}
I also tried something like
params.permit(product_builder_permissions:[0][:builder_id.to_s.to_i, :maker_id.to_s.to_i])
to no avail.
Thanks in advance.
Upvotes: 1
Views: 532
Reputation: 20253
Given that you're not doing mass assignment, I suggest you skip the heartache of strong parameters and just manipulate the parameters directly.
Upvotes: 1