如何正确设置集合选择?

时间:2013-01-03 01:55:39

标签: ruby-on-rails ruby-on-rails-3 view

使用下面的代码,如果我点击搜索,则会将我带到这些网址

With FireFox > http://example.com/shop?utf8=%E2%9C%93&genre[]=1
With Safari  > http://example.com/shop?utf8=✓&genre%5B%5D=1

如何删除此“[]”和“%5B%5D”?
只有我想要的是“& genre = 1”

查看代码

<%= form_tag communities_path, :method => :get, :class => 'form-search' do %>
   <div class="input-append">
    <%= collection_select :genre, nil, Genre.all, :id, :name %>
    <button type="submit" class="btn">Search</button>
   </div>
<% end %>

1 个答案:

答案 0 :(得分:1)

<%= select_tag :genre, options_for_select(Genre.all.map{ |g| [g.name, g.id] }) %>