0
在我的Rails應用程序中,如果用戶提供了國家/地區,我希望f.country_select爲user's country
。否則我希望它具有Select one value
。f.country_select選項默認國家
<%= f.country_select :country, nil, {:selected => @user.country, :include_blank => 'Select one'}, {:class=>'form-control'} %>
上述代碼有問題嗎?
更新:使用gem 'country_select'
上午。
什麼'@ user.country'?你可以使用'@user.country ||嗎? 「選擇一個值」? – radubogdan