1
votes

With the parameters below

Parameters: {"authenticity_token"=>"", "work_week_form"=>{"work_hours"=>[{"day"=>"monday", "start_hour"=>"8", "end_hour"=>"17"}, {"day"=>"tuesday", "start_hour"=>"8", "end_hour"=>"17"}, {"day"=>"wednesday", "start_hour"=>"8", "end_hour"=>"17"}, {"day"=>"thursday", "start_hour"=>"8", "end_hour"=>"17"}, {"day"=>"friday", "start_hour"=>"8", "end_hour"=>"17"}, {"day"=>"saturday", "start_hour"=>"8", "end_hour"=>"17"}, {"day"=>"sunday", "start_hour"=>"8", "end_hour"=>"17"}]}, "button"=>""}

Why params.require(:work_week_form).permit(work_hours: []) raise Unpermitted parameter: :work_hours?

1
can you try by change params.require(:work_week_from).permit(:work_hours) - Kamal Panhwar
Same outcome. Also .permit('work_hours' => []) doesn't work. - Sig
Try explicitly permitting the nested attributes too params.require(:work_week_form).permit(work_hours: [:day, :start_hour, :end_hour]) - David

1 Answers

2
votes

In case of array of hashes you need to define keys individually, Like we need to specify in case of parent child relationship. check here

You can check solution here as well.

params.require(:work_week_form).permit(work_hours: [:day, :start_hour, :end_hour])