assets:precompile connects to DB when initialize_on_precompile is false

橙三吉。 提交于 2019-12-11 12:52:21

问题


I have config.assets.initialize_on_precompile = false in my config/application.rb and bundle exec rake assets:precompile still attempts to connect to my DB. I changed my db name in database.yml to a non-existent database so I can tell when it's trying to connect.

$ be rake assets:precompile
rake aborted!
FATAL:  database "aaa" does not exist

回答1:


According to Heroku, this config is only available in Rails 3.x. You can also see here in rails/rails repo on Rails 4 that the config for assets isn't there anymore: https://github.com/rails/rails/blob/master/railties/lib/rails/application/configuration.rb

For quick assets compiling, I use a simple sqlite3 config in production. It always connects no matter what. Your database.yml file should not be taken as is from your repo in production anyway. Either you use Heroku or a simple capistrano symlink to your shared folder, or any other custom solution.



来源:https://stackoverflow.com/questions/20008159/assetsprecompile-connects-to-db-when-initialize-on-precompile-is-false

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