The params sent to the controller are not nesting correctly as seen
below.
<% fields_for "discount_code[new_discount][]
", task do |form| %>
Tour Type ID: <%= form.text_field :tour_type_id %>
Price: <%= form.text_field :price_number %>
Days: <%= form.text_field :days %>
<% end %>
I would expect this to come into the controller looking like
parameters : {“discount_code” =>
{“new_discount” => [
{“tour_type_id” => ‘8’, “price_number” => ‘8.00’, “days”
=>
‘-1’},
{“tour_type_id” => ‘7’, “price_number” => ‘22.00’,
“days” =>
‘3’}
]
}
Instead - it’s coming in like this:
Parameters : {:discount_code =>
{“new_discount_attributes” =>[
{“tour_type_id”=>“7”},
{“day”=>"-1", “tour_type_id”=>“8”},
{“day”=>“3”, “price_number”=>“22.00”},
{“price_number”=>“8.00”}],