1

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

1
  • 1
    I think you should be placing your project specific assets in app/assets and any third party(external) assets you download for use in your project in vendor/assets. Commented Dec 22, 2013 at 13:54

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.