我正在使用country_code
gem并设法将country_name
转换为index.html.erb
中的Search
。
现在,我创建了一个country_code
模型,我只能使用country_name
但country_name
。知道如何转换这种方式用户可以选择country_code
,但发送参数仍然是class SearchesController < ApplicationController
def new
@search = Search.new
@country = Property.uniq.pluck(:country_code)
end
end
?
searches.controller.rb
<%= form_for @search, html: {class: "pure-form"} do |f| %>
<div class="field">
<%= f.label "Country" %>
<%= f.select :country, options_for_select(@country), :include_blank => true%>
</div>
<div class="actions"><%= f.submit "Search", class: "btn" %></div>
<% end %>
new.html.erb
copy <TABLE> FROM <FILE> with DELIMITER = '\t' AND NULL = 'NULL' AND QUOTE = '\"' AND ESCAPE = '\\';
答案 0 :(得分:0)
您可以仅使用:限制国家/地区。
@limit_country = Property.pluck(:country).uniq
<%= form_for @search, html: {class: "pure-form"} do |f| %>
<div class="field">
<%= f.label "Country" %>
<%= f.country_select :country, only: @limit_country, include_blank: true
</div>
<div class="actions"><%= f.submit "Search", class: "btn" %></div>
<% end %>