How can I force Heroku to run assets:precompile if Rails isn't autodetected?
-
25-10-2019 - |
Question
I have a Rails 3.1 application with an usual file layout. Heroku detects it as Ruby/Rack rather than Ruby/Rails. assets:precompile
isn't run, so pages that require them fail with a javascript error.
What do I need in my file structure to trick Heroku into running the precompile task? Or, can I configure a command to run during slug compilation?
Solution
Do you have have a config/application.rb
in your codebase? This is what the Heroku ruby buildpack uses to detect that it's Rails 3, so it sounds to me like this could be missing.
Once Heroku detects that it's Rails it'll run the rake assets:precompile
.
Failing that, you could use a gem such as heroku_san
to add a post deploy hook of heroku run rake assets:precompile
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow