ransack icon indicating copy to clipboard operation
ransack copied to clipboard

Multiple select

Open TvL2386 opened this issue 15 years ago • 4 comments

Hi ernie, I've been a happy user of meta_search and now ransack. What I want is a select box with multiple select possibilities. I have "f.select :level_in, Log.levels, { :include_blank => true, :multiple=>true,:size=>6 }" But the :multiple and :size do not work. I don't know if they are supposed to work. I would think that when choosing the predicate _in, you can select multiple options. Maybe this is a nice feature?

With kind regards, Tom

TvL2386 avatar Jul 13 '11 08:07 TvL2386

Multiple selects should indeed work. I'll check this out soon.

ernie avatar Jul 15 '11 10:07 ernie

Hello, I have similar issue. I want to have many selects, for one query. I have examined demo-app and I know that something like this should work. However, I don't know, how to write it.

= f.fields_for :kitchens_name_cont_any do |k| = k.select ??, Category.find_all_by_category_type('Kitchen') = k.select ??, Category.find_all_by_category_type('Kitchen')

Thanks for any kind of help. Michael

mican avatar Jul 20 '11 15:07 mican

0.5.4 should resolve this. If you do something like:

f.collection_select :some_id_in, Model.all, :id, :name, {}, {:multiple => true}

ernie avatar Jul 24 '11 21:07 ernie

Hi Ernie, Thanks for fixing this. I have to do the following to get the select field I want: = search_form_for @search do |f| = f.collection_select :level_in, Log.levels, :to_s, :to_s, {}, { size: Log.levels.length, multiple: true }

It took some experimenting to understand what you meant with :id and :name, but I got it.

TvL2386 avatar Jul 25 '11 05:07 TvL2386