I am new to rails from java enviroment. I have few confusions in asset pipeline with rails 3 to 4.
Currently I am in rails 4.2.5 I created a sample app on my local environment. I created a new js from inside app/assets/javascripts and referencing it from the view , everything seems to working fine on my local environment.
After this I thought to test with production env how it works. Here are the steps I did.
- RAILS_ENV=production rake assets:clean assets:precompile [All the files created public/assets]
- Started the server in production mode rails server -e production
- Now when i browsed the page I am getting this error,
"NetworkError: 404 Not Found - http://localhost:3000/assets/application-c5c431cb7c0a202f831a634922aaf1d536712002ae74334fb03ba4698b32b84c.js"in firebug.
When searched few threads , they suggest to add config.assets.compile = true. But I do not think so this is what the solution is, as it slows down the app.
Please help.
I suggest you have a look at the rails_12factor gem, which includes the rails_serve_static_assets gem which will allow your Rails app to serve static assets (like your .js file).
Edit:
You may not need a gem for this (though I've not tried it):
In Rails 5, this config method has been renamed to
config.public_file_server.enabled, the rails_serve_static_assets gem handles the correct naming depending on version.