cat
cat

Reputation: 749

How can I set up collection select correctly?

With the code below, if I hit Search it takes me to these url

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

How can I remove this "[]" and "%5B%5D"?
Only I want is "&genre=1"

View code

<%= 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 %>

Upvotes: 0

Views: 32

Answers (1)

Kyle
Kyle

Reputation: 22258

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

Upvotes: 1

Related Questions