我有2個模型「國家」和「聯賽」,國家有很多聯賽和聯賽屬於國家。當添加一個聯賽,我有國家列表框和表單提交時,實際的國發:國家預期,得到字符串錯誤
{"commit"=>"Create League",
"authenticity_token"=>"wuAuj5vowkk2R56TuFkWE8J3x3vue5RbnNPcbpjuG3Q=",
"utf8"=>"âœ「",
"league"=>{"league_short"=>"CL",
"country"=>"England",
"level"=>"2",
"league"=>"The Championship"}}
但後來我收到此錯誤信息:
Country expected, got String
在全國模型我有country_id(整數)和國家(字符串)作爲字段,在聯盟模型中我有國家作爲字符串字段。在聯盟控制器中,我有這樣的下拉菜單:@countries = Country.dropdown_list
。在聯盟/新視圖中,我有這個選擇字段:<%= f.select :country, @countries %>
。出了什麼問題?
謝謝,工作! – John 2011-04-20 05:42:13
我只是這樣做了:'<%= f.select:artist,Artist.all.collect {| a | [a.name,a.id]}%>'並且得到了這個'藝術家(#2198585660)預計,得到了String(#2151988680)' – 2011-05-10 15:50:10