Ruby 使用带有form_标签且无型号的country_select gem
我在表单标签中使用Rails 4中的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
<%= 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])