Rails - drop down from an array of strings

drop-down-menu, forms, ruby-on-rails

Solution

You need to use options_for_select helper like

<%= select_tag "city", options_for_select([['New York' ,'New york'], ['Los Angeles', 'Los Angeles']]) %>

Problem

I have an array like this: ``` ['New York', 'Los Angeles'] ``` And I want to be able to generate a select/option with those values in a form like this: ``` <%= form_tag filter_city_path, :method=> get do %> <%= select_tag "city", @list_of_cities %> <% end %> ``` But this is not working. As you can see I want to pass the selection as city in the url.

Original source