Multiple select issue with a HABTM relationship using Rails 4

后端 未结 2 1501
忘掉有多难
忘掉有多难 2020-12-25 12:23

Although the code seems to be right, when I try to send the form, the values of the multiple select aren\'t being sent.

If I just remove the multiple option, everyth

相关标签:
2条回答
  • 2020-12-25 13:04

    Be sure what you properly allow received params for mass assignment.

    You said that the one param works, so I assume what you have somewhere in your controller something like:

    params.require(:transaction).permit(:name, :tag_ids)
    

    So you need allow to receive an array:

    params.require(:transaction).permit(:name, :tag_ids => [])
    
    0 讨论(0)
  • 2020-12-25 13:07

    I solved my problem using

    {:health_unit_ids => []}
    

    Rails 4 no accepted without {}

    0 讨论(0)
提交回复
热议问题