如何修复Rails错误:未配置开发数据库 - ActiveRecord :: AdapterNotSpecified

时间:2016-02-03 06:05:03

标签: ruby-on-rails activerecord

尽管我试图改变很多东西,但我一再得到这个错误。

我查看了其他SO页面并更改了缩进,名称等。真的不确定发生了什么。任何见解将不胜感激。

# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
 default: &default
 adapter: postgresql
 pool: 5
 timeout: 5000

 development:
 <<: *default
 database: lightpath_development

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: lightpath_test

production:
<<: *default
database: lightpath_production

1 个答案:

答案 0 :(得分:0)

尝试切换回默认的database.yml文件。

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
#
default: &default
  adapter: sqlite3
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: db/test.sqlite3

production:
  <<: *default
  database: db/production.sqlite3

您可能会收到该错误,因为您没有在开发计算机/服务器上正确配置Postgres,而是尝试使用Postgres数据库。

有关如何切换到postgres的详细信息,您应该看this RailsCast episode