mondayguy
mondayguy

Reputation: 991

rails multiple params(:filter) request

When i use select with multiple options, form send such get request:

/saveProduct?tags=1&tags=2

so I need to get them with params[:tags], but it takes only last string. How to get all of them?

EDIT:

<%= form_tag("/saveProduct", multipart: true, method: :get) do %>
 <select multiple="multiple" class="tagsSelect" name = "tags" >
    <option value = 1 >123</option>
     <option value = 2 >dfsd</option>
</select>
<% end %>

Upvotes: 0

Views: 217

Answers (1)

RAJ
RAJ

Reputation: 9747

Your select's name attribute should be tags[] to support multiple values.

<select multiple="multiple" class="tagsSelect" name = "tags[]" >

Now when you will do params[:tags] you will get an array of values in your action.

How to pass an array within a query string

Upvotes: 3

Related Questions