Country expected, got String error

后端 未结 6 1207
栀梦
栀梦 2020-12-10 16:38

I have 2 models \"Country\" and \"League\", Country has many Leagues and League belongs to Country. When adding a league, I have a listbox with countries and when the form i

6条回答
  •  春和景丽
    2020-12-10 17:32

    You need to use :country_id instead of :country

    <%= f.select :country_id, Country.all.collect {|c| [c.name, c.id]} %>
    

提交回复
热议问题