I've deployed a new version of a Rails 5 app on Heroku, running on cedar-14 stack. It didn't precompile while deploying, so I did heroku run rake assets:precompile
manually. Still, I can see it includes old assets while requiring css
and js
files.
My files are in app/assets
so it's not possible that directory isn't in assets compile path.
My config on application.rb
and production.rb
:
config.assets.compile = true
# I checked the environment variable, it responds to 'enabled',
# which would return true for the option.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Which I changed to expire old assets.
config.assets.version='1.1'
I tried these, but they didn't work:
$ heroku restart
$ heroku run rake assets:precompile
$ heroku run rake assets:clobber
The weird thing with these is that they do not affect assets in heroku server, which I checked with $ heroku run ls public/assets
. Even after $ rake assets:precompile
, even though it says this:
WRITING /app/public/assets/application-{VERY_LONG_HASH}.js
WRITING /app/public/assets/application-{VERY_LONG_HASH}.js.gz
WRITING /app/public/assets/application-{VERY_LONG_HASH}.css
WRITING /app/public/assets/application-{VERY_LONG_HASH}.css.gz
when I peek with the $ heroku run ls public/assets
, I still see old assets staying there.
EDIT: I solved it by deleting all the local assets in public/assets
, recompiling them with $ rake assets:clean && rake assets:precompile
and including these assets in my git
repository. Here is one concern:
Shouldn't heroku be responsible of compiling my assets on the fly? I think I shouldn't be compiling my assets everytime I deploy my application. Thanks.
assets:clobber
andassets:precompile
inside aheroku
instance of app instead of doing that in your local instance and pushing to heroku. And about your question, I wonder that too since I have started using heroku (i.e 1 year). – Granulation