Reputation: 2973
bundle exec rake assets:precompile RAILS_ENV=production
. My website can't load javascript file and css file. But when i ran it on development environment, everything were well.
The problem was here if in config/environments/production.rb
, and i set this line was true
same as config.assets.compile = true
. Everything was fine.
config.assets.compile = false
. My website can't load css file and javascript file. Hope everybody can explain for me ? Thank you very much.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
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