Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chosen-rails gem not working

I've read many other related questions and just cannot get this gem to work:

https://github.com/tsechingho/chosen-rails

as the README says, I have

-included *= require chosen in my application.css

-included //= require chosen-jquery in my application.js 

In addition, I have tried adding the followin to the bottom of my application.js file:

jQuery(function($){
    $('.chzn-select').chosen();
});

I've also replaced .chzn-select with #user_education_ids and #user_school_ids based on my model and view:

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

I've tried adding , :class=>'chzn-select' to the end of :multiple => true, no luck

(A User has many Educations, as well as many schools through educations)

Not sure why this is giving me so much trouble, but it is. Help is very much appreciated!

like image 424
keypulsations Avatar asked Nov 13 '22 23:11

keypulsations


1 Answers

I know this is a little late, but I had a problem getting it to work as well.

I got it to work by moving the line "gem 'chosen-rails'" outside of the :assets block in the Gemfile (I noticed your comment on the associated Railscast, where Ryan put it in the :assets block, so I'm assuming you did as well).

I'm not sure if that's the "right" solution, or what the side effects might be, but it appears to be working now.

like image 182
franl Avatar answered Nov 15 '22 11:11

franl