How can I turn off asset compilation completely on a rails app on Heroku?

穿精又带淫゛_ 提交于 2020-01-03 17:24:12

问题


I have a rails app which runs a service which has no assets. When I deploy, I see:

-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       rake aborted!
       could not connect to server: Connection refused
       Is the server running on host "127.0.0.1" and accepting
       TCP/IP connections on port 5432?
       /tmp/build_3pneyggcg60ks/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `initialize'
       /tmp/build_3pneyggcg60ks/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `new'
       /tmp/build_3pneyggcg60ks/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `connect'
...

So I put this into my application.rb:

config.assets.enabled = false
config.serve_static_assets = false
config.assets.compile = false

But I still get the very same message when deploying.

How can I completely turn off asset compilation/handling on heroku?


回答1:


See this question and the docs. It looks like the magic occurs in the manifest.yml file.




回答2:


Found this on https://devcenter.heroku.com/articles/rails-asset-pipeline

While precompiling assets, in Rails 3.x, you can prevent initializing your application and connecting to the database by ensuring that the following line is in your config/application.rb:

config.assets.initialize_on_precompile = false


来源:https://stackoverflow.com/questions/17845889/how-can-i-turn-off-asset-compilation-completely-on-a-rails-app-on-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!