I am trying to achieve a multi select drop down menu using options_for_select
for this simple app but I can't get it to work.
My model search.rb
class Search < ActiveRecord::Base
def search_books
books = Book.all
books = books.where(["market LIKE ?",market]) if market.present?
return books
end
My search_controller.rb
def new
@search = Search.new
@markets = Book.uniq.pluck(:market)
end
My search form
<%= form_for (@search) do |f| %>
<div class="field">
<%= f.label :market %><br>
<%= f.select :market, options_for_select(@markets),:multiple => true, :include_blank => true, :prompt=>'All' %>
My Books Table
create_table "books", force: :cascade do |t|
t.string "name"
t.string "market"
t.string "function"
............................. omitted
With these code, I can get a single select dropdown menu but I need a multi select drop down menu. Thanks