0

I'm using Rails form. I know how to get an option to remain in the form when multiple: false (thanks to this post: rails erb form helper options_for_select :selected ) but I'm having problems when I have multiple: true as nothing stays highlighted when you go back to edit.

Edit Form:

<%= p.label :basement %>
    <%= p.select :basement, options_for_select(["Apartment", "Finished", "Partially finished", "Separate Entrance", "Unfinished", "Walk-out", "None"],selected: p.object.basement), {include_blank: false} ,{multiple: true} %>    


    <%= p.label :flooring %>
    <%= p.select :flooring, options_for_select(["Bamboo","Carpet", "Engineered Hardwood", "Hardwood", "Laminate", "Marble"],selected: p.object.flooring), {include_blank: false} ,{multiple: true} %>

Controller:

...    
def params
        params.require(:property).permit({basement:[]},{flooring:[]})
    end

Can anyone help me understand what I might be missing to get this to work?

Community
  • 1
  • 1
dgreen22
  • 388
  • 4
  • 19

1 Answers1

0

Easiest way would be to use a jquery library like chosen: https://harvesthq.github.io/chosen/ or select2: https://select2.github.io/examples.html

toddmetheny
  • 4,405
  • 1
  • 22
  • 39