0

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 %>
mondayguy
  • 973
  • 2
  • 12
  • 34

1 Answers1

3

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

Community
  • 1
  • 1
RAJ
  • 9,697
  • 1
  • 33
  • 63