M
M
Max2015-12-02 15:04:34
Ruby on Rails
Max, 2015-12-02 15:04:34

How to implement multiselect in select (rails)?

Hello, there is a table with drug prices.
I need to make a selection of several drugs from select, because now I can only select one drug.

<%= f.select( :user_prices, Price.all.map {|c| [c.title]}, {:multiple=>true}) %>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dima, 2015-12-02
@maxprof

Do this:
<%= f.select( :user_prices, Price.all.map {|c| [c.title, c.id ]}, {} , {:multiple=>true}) %>
`select` method takes 3 parameters + hash.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question