Rails : How to add plugins to vendor directory

Just move the files to `vendor/assets’ and it starts working.. but ( a big but)

  • Jquery plugins moved to vendor/assets wont load because
    • Rails loads the vendor files first and your assets later
    • means your Jquery Dependent plugins wont find jQuery installed

To solve this issue you need to do this

//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require_tree ../../../vendor/assets/javascripts/.
//= require_tree .

In this way, you can get your work done

  • if some of your dependencies need to be loaded in an order then you must require them manually in `application.js`
    • //= require jquery
      //= require jquery-ui
      //= require dependency_1
      //= require dependency_2
      //= require_tree ../../../vendor/assets/javascripts/.//= require_tree .
  • They are not loaded twice but once; rails is smarter

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s