,英国“,”维尔京群岛,美国“, “瓦利斯和富图纳群岛”,“西方人
,英国“,”维尔京群岛,美国“,
“瓦利斯和富图纳群岛”,“西方人
撒哈拉 </跨度> “,”“也门”,“赞比亚”,“津巴布韦”,除非const_defined?(“国家”) 结束
class InstanceTag def
class InstanceTag
def
检查country_select gem的版本。它似乎最近更新为符合Rails 4.x中引入的更改。您需要v1.1.1或更高版本。
不幸的是,关于这方面的文档有点稀疏。当你的 country_select 在一个表格内(即你正在使用 f.country_select …)你不需要提供 object 既然你已经拥有了 form_for(object) 。
country_select
f.country_select
object
form_for(object)
我在Rails 3.2.17和country_select 1.1.3中成功使用了以下语法:
form_for(myobject) do |f| … f.country_select “country”, [“Australia”, “New Zealand”], {}, {class: “form-control”, id: “country”} …end</code>
form_for(myobject) do |f| … f.country_select “country”, [“Australia”, “New Zealand”], {}, {class: “form-control”, id: “country”} …end
</code>
“country” 是的属性 myobject ,澳大利亚和新西兰是优先国家,空洞 {} 是选项,其余的是html_options。
“country”
myobject
{}
我必须安装另一个gem来解决Rails版本4.2.0中的相同错误:
wrong number of arguments(4 for 0)
宝石被指定为:
gem ‘country_select’, github: ‘stefanpenner/country_select’</code>
gem ‘country_select’, github: ‘stefanpenner/country_select’
在你的Gemfile中,然后运行 bundle install 并重新启动服务器。我找到了这个解决方案 这里 。
bundle install
尝试更改视图
而不是
f.country_select(‘country’) </code>
f.country_select(‘country’)
country_select(:user, :country)</code>
country_select(:user, :country)