我想在搜索表单中使用国家/地区选择,并且想知道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_tag
更改为country_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
并填写模型中的国家/或是否有其他解决方案
答案 0 :(得分: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