0

我想在搜索表单中使用国家/地区选择,并且想知道 contry_select_tag 不适用于 form_tag

我试过以下

<%= form_tag new_search_path  :html => {:multipart => true} do %>
   <%= text_field_tag :search_val%>
   <%= country_select_tag :country,[],["Germany", "France", "Austria", "Switzerland", "Netherlands", "Spain", "USA", "Russia"]%>

   <%= submit_tag "Search" %>
<%end%>

并收到以下错误消息

undefined method `country_select_tag' for #<#<Class:0xb6640828>:0xb5d06d5c>

更改country_select_tagcountry_select我没有错误,但:country参数params保持为空

!ruby/hash:ActiveSupport::HashWithIndifferentAccess
utf8: ✓
authenticity_token: GbmhaZAuSA3s88pTz+ZQJ6mxqZ1nrTpgSlSf40vttUY=
search_val: Test
country: 
commit: Search
html: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
  multipart: 'true'
controller: searches
action: results

我需要使用法线select_tag并用模型中的国家/地区填充它还是有其他解决方案

4

1 回答 1

0

尝试删除国家部分

  <%= form_tag new_search_path  :html => {:multipart => true} do %>
       <%= text_field_tag :search_val%>
       <%= select_tag :country,[],["Germany", "France", "Austria", "Switzerland", "Netherlands", "Spain", "USA", "Russia"]%>

       <%= submit_tag "Search" %>
    <%end%>

更多信息在这里http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html

于 2013-03-18T12:48:17.440 回答