gpt4 book ai didi

ruby-on-rails - Rails/ActiveRecord - AdapterNotSpecified,即使它是

转载 作者:数据小太阳 更新时间:2023-10-29 06:55:59 24 4
gpt4 key购买 nike

我正在做 Ruby on Rails Tutorial.对于前三章,它使用 SQLite,但后来它建议在开发中使用 PostgreSQL,以便更轻松地部署 Heroku。在编辑我的 database.ymlGemfile 以使用 pg 而不是 sqlite3 之后,它似乎可以工作 - 使用 Rake 运行测试时除外。它会弹出一个 AdapterNotSpecified 错误。

C:/Ruby/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/
connection_adapters/connection_specification.rb:52:in resolve_hash_connection':
数据库配置没有指定适配器(ActiveRecord::AdapterNotSpecif
ied)

等等

database.yml 指定一个适配器,如下所示:

development:
adapter: postgresql
host: localhost
username: nekkoru
password: derpderp
database: development
encoding: UTF8

这是怎么回事?我在 Windows 7 x64、Ruby 1.9.3、Rails 4.0.0、PostgreSQL 9.3.0.1 上。

最佳答案

您没有为测试环境定义数据库。您的 database.yml 文件应如下所示:

development:
adapter: postgresql
host: localhost
username: nekkoru
password: derpderp
database: development
encoding: UTF8

test:
adapter: postgresql
host: localhost
username: nekkoru
password: derpderp
database: test # or whatever the name is
encoding: UTF8

关于ruby-on-rails - Rails/ActiveRecord - AdapterNotSpecified,即使它是,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19066935/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com