Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 创业板国家选择帮手_Ruby On Rails_Country - Fatal编程技术网

Ruby on rails 创业板国家选择帮手

Ruby on rails 创业板国家选择帮手,ruby-on-rails,country,Ruby On Rails,Country,我正在尝试使用来自hexorx的gemcountries。我真的不知道如何把它带到select助手中。我试着像这样使用助手country\u select <%= f.country_select :country, :required => true %> true%> gem的GitHub位置是 此帮助器的接口定义为: country_select(object, method, priority_countries = nil, options = {}, html_

我正在尝试使用来自hexorx的gem
countries
。我真的不知道如何把它带到select助手中。我试着像这样使用助手
country\u select

<%= f.country_select :country, :required => true %>
true%>

gem的GitHub位置是

此帮助器的接口定义为:

country_select(object, method, priority_countries = nil, options = {}, html_options = {})
我通过访问您提供的链接,浏览源代码找到了这一点

假设这是在对象实例上操作的
形式,可能是
@user
,那么用户实例就是第一个参数
object
的传递对象。第二个参数,
method
是应该接收所选值的对象的属性,因此在本例中,您的用户模型需要有一个名为
country
的属性

因此,问题很可能是第三个参数需要一个
优先权国家列表
,但它得到了
:required=>true
。如果你通过了
nil
,然后通过了你的选项,它应该可以工作,如下所示:

<%= f.country_select :country, nil, :required => true %>
true%>
对于以后的帖子,当某些东西不起作用时,您应该提供您看到的完整错误消息或症状