ActiveRecord :: NoDatabaseError错误:数据库“ db / development.postgresql”不存在 [英] ActiveRecord::NoDatabaseError FATAL: database "db/development.postgresql" does not exist

查看:203
本文介绍了ActiveRecord :: NoDatabaseError错误:数据库“ db / development.postgresql”不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个小型应用程序,它正在本地运行。然后,当我将其部署到Heroku上时,该错误在我的终端中弹出:

I'm building a small app and it was working locally. Then when I went to deploy it on Heroku, this error popped up in my terminal:

remote:        An error occurred while installing sqlite3 (1.3.11), and 

Bundler cannot
remote:        continue.
remote:        Make sure that `gem install sqlite3 -v '1.3.11'` succeeds before bundling.
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !     
remote:  !     Detected sqlite3 gem which is not supported on Heroku.
remote:  !     https://devcenter.heroku.com/articles/sqlite3
remote:  !
remote: 
remote:  !     Push rejected, failed to compile Ruby app
remote: 
remote: Verifying deploy...
remote: 
remote: !   Push rejected to pockettheskimm.
remote: 
To https://git.heroku.com/pockettheskimm.git
 ! [remote rejected] master -> master (pre-receive hook declined)

我随后阅读Heroku上的文档,该文档告诉我必须在应用程序中使用Postgres而不是sqlite3。所以我更新了我的应用程序,将sqlite3换成了Postgres:

I subsequently read the documentation on Heroku, which told me that I have to use Postgres in my app instead of sqlite3. So I updated my app, swapping out sqlite3 for Postgres:

default: &default
  adapter: postgresql
  pool: 5
  timeout: 5000

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

# 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.postgresql

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

但是现在当我在本地运行应用程序时,我的浏览器中出现以下错误:

but now when I run the app locally, I get this error in my browser:

ActiveRecord::NoDatabaseError
FATAL: database "db/development.postgresql" does not exist

Extracted source (around line #661):
659
660
661
662
663
664

        rescue ::PG::Error => error
          if error.message.include?("does not exist")
            raise ActiveRecord::NoDatabaseError.new(error.message, error)
          else
            raise
          end

我该怎么解决?

推荐答案

这是对我有用的答案:

您跑了 rake db :更改完database.yml配置文件后,在开发中创建db:migrate

贷方< a href = https://stackoverflow.com/users/163640/eugen> https://stackoverflow.com/users/163640/eugen

这篇关于ActiveRecord :: NoDatabaseError错误:数据库“ db / development.postgresql”不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆