Khanh Pham
Khanh Pham

Reputation: 2973

Error can't load css vs javascript when run rake assets:precompile on rails 4.2.0

Here is my application.css vs application.js

/*
*= require_self
*= require_tree .
*/

This is my application.js file:

//= require jquery_ujs
//= require jquery-ui.min
//= require plugins/back-to-top

And this is application.html.erb

<%= stylesheet_link_tag  'application', media: 'all'%>
<%= javascript_include_tag "application" %>

Upvotes: 1

Views: 526

Answers (1)

Deepesh
Deepesh

Reputation: 6418

In rails previously the assets were placed in public folder but now all the assets are located in the assets folder. The setting:

config.assets.compile = true

makes the live compilation enabled. In the live compilation all the assets are handled by sprockets. In the first time the assets is cached and compiled and their names are altered using a MD5 hash.

Now you have precompiled assets which gets stored in the public folder and to server assets from public folder you need to set:

config.serve_static_files = true

So set it to true and restart the server and check again.

More details:

http://guides.rubyonrails.org/asset_pipeline.html#in-production

Upvotes: 1

Related Questions