database configuration does not specify adapter

After 24 hours of trying to find the problem with my app. I finally found the problem.

I ran

rake assets:precompile RAILS_ENV=production

and i kept on getting this error.

/Users/vezu/.rvm/rubies/ruby-1.9.3-p194/bin/ruby /Users/vezu/.rvm/gems/ruby-1.9.3-p194@global/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
database configuration does not specify adapter

Tasks: TOP => environment
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/Users/vezu/.rvm/rubies/ruby-1.9.3-p194/bi...]

My database.yml file looks like this

development:
  adapter: postgresql
  host: localhost
  encoding: unicode
  database: ndoda_development
  pool: 5
  username:
  password:

test:
  adapter: postgresql
  encoding: unicode
  database: ndoda_test
  pool: 5

The simple solution was to add one simple line to my application.rb

config.assets.initialize_on_precompile = false

And everything works.


This should work: rake assets:precompile RAILS_ENV=development

It tries to load up your production environment, when your database.yml doesn't include it.


Do this:

development:
  adapter: postgresql
  host: localhost
  encoding: unicode
  database: ndoda_development
  pool: 5
  username:
  password:

test:
  adapter: postgresql
  encoding: unicode
  database: ndoda_test
  pool: 5

# Add the below...

production:
  adapter: postgresql
  host: localhost
  encoding: unicode
  database: ndoda_production
  pool: 5
  username:
  password:

Heroku will overwrite your database.yml with its own version, regardless of what you put in there. However , your rake task running in the Production environment requires a variable, so give it a dummy one.

As noted above, you can also add 'config.assets.initialize_on_precompile = false' to your production.rb. If set, Heroku requires it be set to 'false'.

链接地址: http://www.djcxy.com/p/79988.html

上一篇: Heroku不会在Rails 4的资产管道下编译文件

下一篇: 数据库配置不指定适配器