Html 获取选项\u以选择要保留的多个选定项目

Html 获取选项\u以选择要保留的多个选定项目,html,forms,ruby-on-rails-4,Html,Forms,Ruby On Rails 4,我正在使用Rails表单。我知道当multiple:false(感谢这篇文章:)时如何在表单中保留一个选项,但当我有multiple:true时,我遇到了问题,因为当你返回编辑时,没有任何内容会突出显示 编辑表格: <%= p.label :basement %> <%= p.select :basement, options_for_select(["Apartment", "Finished", "Partially finished", "Separate Ent

我正在使用Rails表单。我知道当
multiple:false
(感谢这篇文章:)时如何在表单中保留一个选项,但当我有
multiple:true
时,我遇到了问题,因为当你返回编辑时,没有任何内容会突出显示

编辑表格:

<%= 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} %>

有人能帮我理解我可能缺少什么才能让它工作吗?

最简单的方法是使用jquery库,如selected:或select2:

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