How to load vendor asset folder in Rails 4? How to load vendor asset folder in Rails 4? ruby-on-rails ruby-on-rails

How to load vendor asset folder in Rails 4?


Any folder created directly under assets will be added to the load paths. Files in that folder can be referenced as usual like so:

If you have

  • vendor/assets/custom/js/file.js

  • vendor/assets/custom/css/file.css

then vendor/assets/custom/ will be added to the load paths.

Include your files in the following files by doing the following:

application.js

//= require js/file

application.css.scss

@import "css/file";

Once that's done, make sure to restart your local server, since it is upon starting your server that the load paths get recognized.

Note: to see a list of load paths, type in your terminal rails c, then type Rails.application.config.assets.paths.


If the application you're running has the assets-pipeline activated, it should find your assets after expanding the path in your application.rb

config.assets.paths << Rails.root.join("multipurpose_bookshelf_slider")


I prefer D7na's answer but with a bit of improvement in my opinion.

As long as this is related to assets, I think it is better to be placed in the assets.rb file.

assets.rb:

Rails.application.config.assets.paths << Rails.root.join("multipurpose_bookshelf_slider")