【问题标题】:How to list all countries in select using country_select gem with simple_form如何使用 country_select gem 和 simple_form 列出选择中的所有国家
【发布时间】:2013-08-18 17:56:20
【问题描述】:

我已将gem 'country-select' 添加到我的gemfile 中,我需要在一个选择中列出所有国家/地区。我尝试<%= f.input :country, as: :select %>,但国家没有出现。文档中没有关于此的信息。请帮我解决这个问题。

【问题讨论】:

  • 问得好,安德烈。没有此宝石的完整信息。

标签: ruby-on-rails ruby simple-form


【解决方案1】:

试试这个

<%= f.input :country, as: :country %>

【讨论】:

  • 如果我可以补充一点:您不需要as: :country 参数,因为名称中包含country 的属性会自动映射到国家/地区选择。见documentation
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-27
  • 1970-01-01
  • 1970-01-01
  • 2015-10-12
  • 1970-01-01
相关资源
最近更新 更多