1

My layout references:

  <%= stylesheet_link_tag    "application", media: "all", "data-turbolinks-track" => true %>
  <%= javascript_include_tag "application", "data-turbolinks-track" => true %>

which renders in the html page on staging and production as:

  <link data-turbolinks-track="true" href="/stylesheets/application.css" media="all" rel="stylesheet" />
  <script data-turbolinks-track="true" src="/javascripts/application.js"></script>

On development, this renders as:

  <link data-turbolinks-track="true" href="/assets/application.css" media="all" rel="stylesheet" />
  <script data-turbolinks-track="true" src="/assets/application.js"></script>

which works.

I have config.assets.compile set to false, but even running rake assets:precompile has no effect - the rails app is still missing /javascripts/application.js and /stylesheets/application.css on staging and production.

Why aren't those assets compiling to /public?

1
  • Where are you deploying the application? heroku/aws..etc? Commented Mar 21, 2014 at 17:16

1 Answer 1

1

In production.rb file you will have config.serve_static_assets = false but you need to set it true because when you compile assets for production mode, i mean always it runs on server in production mode so set it to true, so that for production your assets could compile and you will have all js, css, images running.

config.assets.compile = true
config.serve_static_assets = true
Sign up to request clarification or add additional context in comments.

5 Comments

The server is sitting behind nginx, which is serving the files in /public. The problem seems to be that there is no /public/javascripts/application.js file at all (or the css one).
(Other files which are actually present in /public are being served fine.)
When assets are being compiled, when those two options are enabled then your all css and js will be compressed in form of application.js and application.css with unique hash value. and those files now available to public directory.
But shouldn't running the precompile rake task accomplish the same thing?
@SSR Setting config.assets.compile = true in production environment will decrease performance.

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.