Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.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 使用带有form_标签且无型号的country_select gem_Ruby_Ruby On Rails 4 - Fatal编程技术网

Ruby 使用带有form_标签且无型号的country_select gem

Ruby 使用带有form_标签且无型号的country_select gem,ruby,ruby-on-rails-4,Ruby,Ruby On Rails 4,我在表单标签中使用Rails 4中的country_select gem: <%= form_tag(@url, method: :post, class: "form-horizontal") do %> <div class="form-group"> <%= label_tag(:country_code, "Country code") %> <%= country_select :country_code, @c

我在表单标签中使用Rails 4中的country_select gem:

<%= form_tag(@url, method: :post, class: "form-horizontal") do %>
    <div class="form-group">
      <%= label_tag(:country_code, "Country code") %>
      <%= country_select :country_code, @country_code, class: "form-control" %>
    </div><% end %>

这是一个非常不寻常的错误,我还没有在country_select gem中发现任何其他此类错误。rails应用程序没有数据库,并且正在与外部数据库通信,因此此应用程序中没有模型。有人建议我使用openstruct来解决这个问题。然而,我想知道是否有人知道更快的修复方法?表单正在数据库中提取数据

问题在于我没有模特。我需要使用OpenStruct数据结构来帮助我模拟对象。您可以阅读更多有关它的信息

因为您的应用程序中可能有
国家/地区选择
gem,您也有
国家/地区选择
gem,因为它是
国家/地区选择
的依赖项。因此,您可以使用以下
countries
gem使用普通Rails表单帮助程序
select\u tag
options\u for\u select

select_tag :country, options_for_select(ISO3166::Country.all, params[:country])
这是一个比使用OpenStruct更好的选择


有关详细信息和其他可用于替代ISO3166::Country的查找程序,请参阅。所有这些看起来都是gem问题
select_tag :country, options_for_select(ISO3166::Country.all, params[:country])