Reputation: 5916
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
?
Upvotes: 1
Views: 109
Reputation: 7366
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])
Upvotes: 2