我的路由就是这样。但是如果流派是空的呢?
它不会重定向到 example.com/shops/newest_first//california 吗?
我该如何解决这种路由和参数问题?
路线.rb
match 'shops/:sort/:genre/:area', :to => 'shops#index'
看法
<%= form_tag shops_path, :method => :get do %>
<%= select_tag :sort, options_from_collection_for_select(Sort.all, 'id', 'name', params[:sort]), :prompt => "Newest first" %>
<%= select_tag :genre, options_from_collection_for_select(Genre.all, 'id', 'name', params[:genre]), :prompt => "all" %>
<%= select_tag :area, options_from_collection_for_select(Area.all, 'id', 'name', params[:area]), :prompt => "all" %>
<% end %>
另一种观点