我已经阅读了许多其他相关问题,但无法让这个 gem 工作:
https://github.com/tsechingho/chosen-rails
正如自述文件所说,我有
-included *= require chosen in my application.css
-included //= require chosen-jquery in my application.js
此外,我尝试将以下内容添加到application.js
文件底部:
jQuery(function($){
$('.chzn-select').chosen();
});
我还替换.chzn-select
为#user_education_ids
并#user_school_ids
基于我的模型和视图:
<% @schools = Education.all.map { |e| [ e.school, e.school ] } %>
<%= select_tag "school_ids", options_for_select((@schools), params[:education_id]), { :include_blank => true, :multiple => true } %>
我试过添加, :class=>'chzn-select'
到末尾:multiple => true
,没有运气
(一个用户有很多教育,也有很多学校通过教育)
不知道为什么这给我带来了这么多麻烦,但确实如此。非常感谢您的帮助!