加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql – 如何在rails控制台中查找数据库名称

发布时间:2020-12-13 16:18:30 所属栏目:百科 来源:网络整理
导读:这很奇怪.在我的Rails 4 database.yml中,我有以下内容: development: adapter: postgresql encoding: unicode database: inspector_development password: pool: 5 我从Heroku复制了生产数据库,并使用此表单将其导入到Postgresql的本地副本中 curl -o lates
这很奇怪.在我的Rails 4 database.yml中,我有以下内容:
development:
  adapter: postgresql
  encoding: unicode
  database: inspector_development
  password: 
  pool: 5

我从Heroku复制了生产数据库,并使用此表单将其导入到Postgresql的本地副本中

curl -o latest.dump `heroku pgbackups:url --account personal`
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U sam -d inspector_development latest.dump

结果显示,在osx上的inspector_development数据库中,PGadmin中的88个预期用户.但是,即使重新启动rails应用程序,User表仍然只显示一个用户,而不是我在PGadmin中看到的88.

我已经google了如何确定Rails看到的数据库名称的属性,以确定它在哪里找到这些不存在的记录?

仔细查看PGadmin中的User表,我看到了零列.也许PGadmin错了?我无法确定db Rails正在寻找的位置,以便我可以解决这个问题,thx,sam

这适用于Rails 3和Rails 4
ActiveRecord::Base.connection.current_database

但这仅适用于已实施该方法的驱动程序.例如,它不适用于SQLite,但可以使用mysql和postgres.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读