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 is submitted, the actual country is send:
{"commit"=>"Create League",
"authenticity_token"=>"wuAuj5vowkk2R56TuFkWE8J3x3vue5RbnNPcbpjuG3Q=",
"utf8"=>"a?“",
"league"=>{"league_short"=>"CL",
"country"=>"England",
"level"=>"2",
"league"=>"The Championship"}}
But then I get this error message:
Country expected, got String
In the Country model I have country_id (integer) and country (string) as fields, in the League model I have country as a string field. In the League controller I have this to pouplate the dropdown: @countries = Country.dropdown_list
. In the league/new view I have this select field: <%= f.select :country, @countries %>
. What is going wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…