Looks like you need to qualify your form's inputs for the week_ids
, so that they they form part of the shift
params. At the moment it is posting like this:
{
"shift"=>{
"cod"=>"CN",
"nome"=>"Centrale Notte",
"descr"=>"Operatore Centrale Notte",
"stato"=>"1",
"inizio(4i)"=>"00",
"inizio(5i)"=>"00",
"fine(4i)"=>"08",
"fine(5i)"=>"00"
},
"week_ids"=>["1", "2", "3", "4", ""]
}
Whereas it should be like:
{
"shift"=>{
"cod"=>"CN",
"nome"=>"Centrale Notte",
"descr"=>"Operatore Centrale Notte",
"stato"=>"1",
"inizio(4i)"=>"00",
"inizio(5i)"=>"00",
"fine(4i)"=>"08",
"fine(5i)"=>"00",
"week_ids"=>["1", "2", "3", "4", ""]
}
}
So your form should have this instead:
<%= check_box_tag 'shift[week_ids][]', week.id, @shift.weeks.include?(week) %>