Giancarlo
Giancarlo

Reputation: 23

JS and CSS in Rails 4

In Rails 4, the JS or CSS files, should I putting them in vendor > assets or in app > assets?

Upvotes: 1

Views: 91

Answers (2)

Simone Carletti
Simone Carletti

Reputation: 176562

There are 3 asset locations in Rails

  1. /app/assets/{images,javascripts,stylesheets} for the application-specific assets.
  2. /lib/assets/{images,javascripts,stylesheets} for library assets. It's not very clear the boundary between this folder and the others, there is a lot of overlap. However, you normally place here assets that are shared across multiple apps under your control or libraries that don't normally tie specifically to the application.
  3. /vendor/assets/{images,javascripts,stylesheets} for vendored assets. You should place here assets downloaded from packages where you have no control and that are not intended to be manually edited. This is the case, for instance, of bootstrap, jquery or other frameworks, as well as javascript plugins.

There is one important difference to keep in mind. Assets in /app are reloaded on every request. The other folders are not autoreloaded, thus if you make changes you will need to restart the server.

Upvotes: 4

user229044
user229044

Reputation: 239581

Your CSS goes in app/assets. CSS from 3rd party vendors goes in vendor/assets.

Upvotes: 0

Related Questions