Country expected, got String error

后端 未结 6 1218
栀梦
栀梦 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:16

    You need to send country_id (which is the primary key) instead of name 'England' in that request. The relationships are associated with the primary keys.

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

提交回复
热议问题