Ruby on rails 使用SQLite时无法连接到PostgreSQL?
我得到的错误是: 无法加载“活动\u记录/连接\u适配器/postgresql\u适配器”。确保config/database.yml中的适配器有效 这是我的数据库.yml:Ruby on rails 使用SQLite时无法连接到PostgreSQL?,ruby-on-rails,activerecord,sqlite,Ruby On Rails,Activerecord,Sqlite,我得到的错误是: 无法加载“活动\u记录/连接\u适配器/postgresql\u适配器”。确保config/database.yml中的适配器有效 这是我的数据库.yml: development: adapter: sqlite3 database: db/development.sqlite3 pool: 5 timeout: 5000 production: adapter: postgresql user: test-app encoding: unico
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
production:
adapter: postgresql
user: test-app
encoding: unicode
和我的档案:
# Use sqlite3 as the database for Active Record
gem 'sqlite3', :group => :development
group :production do
# For Heroku
gem 'rails_12factor'
gem 'pg'
end
这个相同的设置可以与另一个应用程序配合使用,但由于某种原因,拒绝在此处使用。为什么它还要在开发中寻找PostgreSQL?在database.yml文件中,生产中的适配器应该是“PostgreSQL”而不是“pg”。我发现了问题所在 我正在使用gem
dotenv
将我的Heroku ENV变量从.ENV
文件加载到Rails中,其中一个是变量ENV['DATABASE\u URL']
中的Heroku Postgres URL,该变量在开发过程中干扰了Rails
我删除了它,Rails再次正常工作。当运行
Rails c
或发送任何web请求时。更改了它,没有任何影响。它甚至不应该在开发过程中查看生产数据库的详细信息。您是否在编辑文件后安装了bundle
?