Hi,
I’m trying to update multiple records from one form but I’m really
struggling with getting the strong parameters right to allow this to
happen…
The records are opening times for each day for stores, the parameters
are passed like so:
{"_method"=>“put”,
“authenticity_token”=>“blah==”,
“open_times”=>
{“1”=>{“day_of_week”=>“0”, “open_closed”=>“1”, “open_at(4i)”=>“07”,
“open_at(5i)”=>“00”, “close_at(4i)”=>“22”, “close_at(5i)”=>“00”},
“2”=>{“day_of_week”=>“1”, “open_closed”=>“2”, “open_at(4i)”=>“07”,
“open_at(5i)”=>“15”, “close_at(4i)”=>“22”, “close_at(5i)”=>“00”},
“3”=>{“day_of_week”=>“2”, “open_closed”=>“0”, “open_at(4i)”=>“09”,
“open_at(5i)”=>“00”, “close_at(4i)”=>“22”, “close_at(5i)”=>“15”}},
“profile_name”=>“testStore”}
and in my controller:
def open_times_params
params.require(:open_times).permit(open_time: [:id, :day_of_week,
:open_closed, :open_at, :close_at])
end
however this does not work…
but gives me this:
Unpermitted parameters: 1, 2, 3
<ActionController::Parameters {} permitted: true>
Unpermitted parameters: 1, 2, 3
Unpermitted parameters: 1, 2, 3
I’m at a loss as to how to get this working although I’m sure it can’t
be as difficult as I am making it…
Any ideas gratefully received!
thanks in advance,
J.