assets:precompile connects to DB when initialize_on_precompile is false
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
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.