gpt4 book ai didi

ruby-on-rails - spring rspec连接不上数据库

转载 作者:太空宇宙 更新时间:2023-11-03 16:43:38 24 4
gpt4 key购买 nike

我有一个新的 Rails 5 应用程序。我按照说明安装了 springspring-commands-rspec gem。我可以自己运行 rspec 并且测试运行良好。但是,如果我运行 Spring binstub bin/rspec 我会得到这个:

Running via Spring preloader in process 227
/usr/local/bundle/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:671:in `initialize': could not connect to server: No such file or directory (PG::ConnectionBad)
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
from /usr/local/bundle/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:671:in `new'
from /usr/local/bundle/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:671:in `connect'
from /usr/local/bundle/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:217:in `initialize'
from /usr/local/bundle/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `new'
from /usr/local/bundle/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
etc...

我有一个使用 binstubs 和 bin/rspec 的 Rails 4 应用程序,效果很好。给了什么?

顺便说一句,rake spec 以同样的方式失败,出现数据库连接错误。

最佳答案

尴尬。我没有正确设置我的 database.yml 以从 *default 继承设置,所以上面的消息字面意思是告诉我没有数据库在运行。修复后,binstub 再次工作。

关于ruby-on-rails - spring rspec连接不上数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39047574/

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