Uri Klar
Uri Klar

Reputation: 3988

Where can i find the chosen.jquery.js file in my rails app?

I'm guessing this is a silly question, but i'm a bit of a newb... I've added the chosen gem to my rails app by adding it to my Gemfile and requiring chosen-jquery in my application.js file.

My question is: where can i find the actual javascript file for chosen? Is it downloading it automatically?

Upvotes: 0

Views: 254

Answers (3)

bershika
bershika

Reputation: 1000

Look up your assets load path. Like this:

  • in terminal cd to your app root
  • then open rails console
  • then run Rails.application.config.assets.paths

Your chosen-jquery is in one of those folders.

Upvotes: 0

KappaNossi
KappaNossi

Reputation: 2716

Simply include the JS and CSS files like described in the documentation on the main page of the Github project and it will be included when precompiling your assets. The files are not within your project directory but rather within the gem and will be resolved by the pipeline when the gem is included.

If you need to get to the file directly (for modifications), you need to put the JS in there manually. You can then still include it in the main application.js for the pipeline and have better control of the version in use. To me, this is the preferred method.

However, may I suggest switching to Select2 which is originally based on Chosen but under much more active development and better documentation:

http://ivaynberg.github.io/select2/

https://github.com/ivaynberg/select2

There's also a gem for it if you like: https://github.com/argerim/select2-rails

Upvotes: 1

Marek Lipka
Marek Lipka

Reputation: 51171

It's in a gem itself. If you look at vendor/assets/javascripts in gem root, you'll see all javascripts that come with chosen gem. They are added by assets pipeline, with

//= require chosen-jquery

line in your application.js.

Upvotes: 0

Related Questions