【问题标题】:database configuration does not specify adapter when preparing asset precompile准备资产预编译时数据库配置未指定适配器
【发布时间】:2014-02-11 19:55:58
【问题描述】:

我最近将我的测试数据库从 sqlite3 切换为 postgrsql。既然这样做了,当我按照此处的说明进行操作时:https://devcenter.heroku.com/articles/rails-asset-pipeline on deploying my assets to heroku,我收到以下错误:

database configuration does not specify adapter

运行此步骤后会发生这种情况

RAILS_ENV=production bundle exec rake assets:precompile

我尝试按照这篇文章中的说明进行操作,但没有成功。

bundle exec rake assets:precompile - database configuration does not specify adapter

我猜这与我的 database.yml 文件有关,该文件位于此处

development:
  adapter: postgresql
  database: playerpong_database
  pool: 5
  timeout: 5000
  encoding: unicode
  host: localhost

有什么想法吗?

【问题讨论】:

    标签: ruby-on-rails heroku heroku-postgres


    【解决方案1】:

    我想通了。我在我的 database.yml 文件中添加了一个生产部分。

    production:
      adapter: postgresql
      database: playerpong_database
      pool: 5
      timeout: 5000
      encoding: unicode
      host: my_app_url
    

    我不认为这是必要的。

    【讨论】:

      【解决方案2】:

      只需传递本文中提到的虚拟数据库即可:

      https://iprog.com/posting/2013/07/errors-when-precompiling-assets-in-rails-4-0

      命令是:bundle exec rake RAILS_ENV=production DATABASE_URL=postgresql://user:pass@127.0.0.1/dbname assets:precompile

      【讨论】:

        【解决方案3】:

        问题是你正在运行

        RAILS_ENV=production bundle exec rake assets:precompile
        

        因为您的文件有开发适配器,所以错误就像适配器丢失一样。 您需要将环境文章更改为开发

        RAILS_ENV=development bundle exec rake assets:precompile
        

        或将开发指令更改为生产

        production:
          adapter: postgresql
          database: playerpong_database
          pool: 5
          timeout: 5000
          encoding: unicode
          host: localhost
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2023-03-27
          • 2014-06-13
          • 1970-01-01
          • 2015-11-26
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多