I have been building a Rails application that I am deploying to Heroku, I had installed a navbar to navigate around the app and it was working completely fine until recently. Now the navbar is not showing up on the application even though it still works perfectly when I try anything locally. I have tried rake assets:precompile, bundle install, and all the usual suspects. I don't know what to do exactly. I have attached screenshots of my app in testing and production. This is the image of the two apps. This error first turned up when I created an account on the production application on Heroku. The logs show this error
ActionController::RoutingError (No route matches [GET] "/assets/~bootstrap/scss/bootstrap")
So if a public/assets/manifest.yml(Rails 4 uses a file called public/assets/manifest-.json instead) is detected in your app, Heroku assumed you are handling asset compilation yourself and will not attempt to compile your assets. On both versions you can generate this file by running $ rake assets:precompile locally and checking the resultant files into Git.
This means that I ran rake assets:precompile locally, even just once, and then checked in that manifest file that would then need to run assets:precompile and check the results into git before every deploy. It's quite a subtle change that can catch people out.
Removing the public/assets/manifest.yml file from my git repo and re-deploying the app, so that asset compilation is done automatically by Heroku again solved the error.
Related
After compiling assets in production, old assets are displayed instead of new assets. Moreover, the compilation was successful and the file with the new assets is present on the server. I tried running rake assets:clean, it didn't help.
What could be the problem and how can it be solved?
I tried running rake assets:clean, it didn't help.
Everything was working fine on my app, after I overhauled the entire front-end design. I attempted to push to my staging server on heroku, and I was getting issues when it was precompiling my assets. So, I attempted rake assets:clobber && rake assets:precompile, and now none of the css is loading in development at all. Syntax errors in my application.sass to bring up error pages, but it's not loading any of the css in my app. In chrome dev tools the only css files showing are SweetAlert css files.
I found the answer. I thought you had to precompile your assets in development, but after some research I found you do not. I clobbered my assets with rake assets:clobber and my css began loading just fine again. Also when pushing to heroku I did nothing else, since heroku precompiles your assets on deployment
I am trying to push to Heroku and my deploy shows as successful but when I look at the app it says:
Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.
When I look at the log the only thing I could find that might be causeing the problem is
Detected manifest file, assuming assets were compiled locally
I have followed the steps from the heroku docs to precompile my assets with rake assets:precompile before pushing to heroku but in the log I never get the message:
-----> Preparing Rails asset pipeline
I am not sure what I am missing?
Thanks
try running rake assets:clobber before you deploy
Sorry if this question sounds basic. But I haven't been able to find an answer anywhere on the web...
I'm currently running my Rails app on a Ubuntu server. Until now I've always shut down the production app before I pull the changes, run rake assets:clean assets:precompile, and only boot up the Rails app again once the process is finished.
I'm not sure whether the shutting down of app is necessary(i.e. if I don't do it, my app will behave erratically). It induces about 5 minutes of down time.
If that's a must, then maybe I should try to do local precompilation/more advanced deployment procedure, in order to reduce downtime? (Tried local compilation according to http://guides.rubyonrails.org/asset_pipeline.html#local-precompilation, but then after deleting original public/assets and pulling locally precompiled public/assets from the repo, the production server was having rack timeout all the time and won't render anything.)
YES you run rake assets:precompile Rails looks through your assets folder and copies over everything that is not Javascript or CSS into public/assets. It then creates application.js by reading app\assets\javascripts\application.js, and application.css by reading app\assets\stylesheets\application.css, loading up all the "require" files it finds in there.
So yes..you can do it ..but if you ran rake assets:clean..and then precompile...then public/assets will be updated with new compiled assets.
Dont forget to restart the server :)
I updated two images and now Heroku is serving one correctly but the other is still the old image. The output of the deploy logs show both images being precompiled with new hashes but the hash used to retrieve one of them (from the application.css file) is still the old hash and it's grabbing the old image somehow.
I'd like to force Heroku to recompile every asset and restart the server (essentially a fresh deploy). Currently it seems to "intelligently" only precompile the assets that it judges as being new. I tried doing rake assets:clobber and rake assets:precompile but it changed nothing -- still using the old hash to grab the old image version for one, but successfully getting the other. Any other options to try?
Expiring the assets manually worked -- changed config.assets.version = 1.0 to 1.1 in config/production.rb. Still not sure what happened, though.
You can now recompile assets without commiting anything.
heroku plugins:install heroku-repo
and then
$ heroku repo:reset --app=appname
$ git push heroku
Source: https://stackoverflow.com/a/9736959/3034747
This command used to accomplish the same thing, but it has been removed and no longer works:
$ heroku repo:rebuild -a appname
Gross, but make a small change and redeploy.
You have to actually redeploy because that's when asset compilation happens and your slug is compiled. Just restarting the server with heroku restart, changing config variables, or pretty much anything else won't build a new slug for you.
I just ran into this problem, and this was at least what solved it for me; YMMV.
Stuff like that can happen - why don't you try using heroku run rake assets:clean and heroku run rake assets:precompile to get the assets cleaned on the server