【问题标题】:Country Select Gem in Rails 4 (gem 'i18n_country_select', '1.1.4')Rails 4中的国家选择宝石(宝石'i18n_country_select','1.1.4')
【发布时间】:2014-12-17 00:11:14
【问题描述】:

我使用 gem 'i18n_country_select', '1.1.4' 进行国家/地区选择,但它不起作用,我已经按照他们的简短文档进行操作。 https://github.com/onomojo/i18n_country_select ..

或者,如果您有类似国家/地区选择的建议宝石,可能会对我有所帮助。

这是我的表格

<%= form_for([@user,@user_profile]) do |f|  %>

<div>
    <%= f.label :firstname, "Firstname" %>
    <%= f.text_field :firstname %>
</div>

<div>
    <%= f.label :lastname, "Lastname" %>
    <%= f.text_field :lastname %>
</div>

<div>
    <%= f.label :birthdate, "Birthdate" %>
    <%= f.date_select :birthdate, :start_year => Date.current.year, :end_year => 1920 %>
</div>

<div>
    <%= f.label :street_address, "Street" %>
    <%= f.text_field :street_address %>
</div>

<div>
    <%= f.label :city_address, "City" %>
    <%= f.text_field :city_address %>
</div>

<div>
    <%= f.label :country, "Country" %>
    <%= f.country_code_select(:user_profile, :country) %>
</div>

<div>
    <%= f.submit "Save Profile" %>
</div>

<% end %>

谢谢!

【问题讨论】:

  • 你能发布你的错误吗?你不应该使用 =country_select 而不是 =f.country_select 吗?

标签: ruby-on-rails ruby ruby-on-rails-4 gem


【解决方案1】:

我认为错误在这一行:

<%= f.country_code_select(:user_profile, :country) %>

必须是:

<%= f.country_select(:user_profile, :country) %>

请测试它并告诉我们它是否有效

【讨论】:

    猜你喜欢
    • 2014-12-12
    • 1970-01-01
    • 1970-01-01
    • 2017-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多