简体   繁体   English

未建立连接Ruby Postgres

[英]Connection Not Established Ruby Postgres

I am getting this error. 我收到此错误。

ActiveRecord::ConnectionNotEstablished
/Users/jod/.rvm/gems/ruby-1.9.3-p194@BankingApp/gems/activerecord-    4.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in `retrieve_connection'
/Users/jod/.rvm/gems/ruby-1.9.3-p194@BankingApp/gems/activerecord-4.0.0.rc1/lib/active_record/connection_handling.rb:79:in `retrieve_connection'
/Users/jod/.rvm/gems/ruby-1.9.3-p194@BankingApp/gems/activerecord-4.0.0.rc1/lib/active_record/connection_handling.rb:53:in `connection'
/Users/jod/.rvm/gems/ruby-1.9.3-p194@BankingApp/gems/activerecord-4.0.0.rc1/lib/active_record/model_schema.rb:208:in `columns'

When trying to run a rake task. 尝试运行rake任务时。 In the rake task it takes Class2 and does a create. 在rake任务中,它使用Class2并进行创建。 This will try to create a record in the database. 这将尝试在数据库中创建一条记录。

I could understand this problem but Class1 is saving to the database and is working fine. 我可以理解此问题,但是Class1正在保存到数据库并且工作正常。 IE if I save a user, it works as expected and if I save a car, it fails. IE,如果我保存用户,则可以按预期工作,如果我保存汽车,则失败。 The classes are identical. 这些类是相同的。

I am using ruby on rails and postgres 我在rails和postgres上使用ruby

When I first got Rails 4 set up, I only needed to set up the gem file to use pg and set up the database.yml file in the config folder to point to the appropriate database and supply it some credentials. 当我第一次设置Rails 4时,我只需要设置gem文件以使用pg并在config文件夹中设置database.yml文件以指向适当的数据库并为其提供一些凭证。

I would assume the task you mentioned in your comments is something that a previous version of Rails did not provide out of the box? 我认为您在评论中提到的任务是Rails的早期版本没有提供的现成功能吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Postgres SSL连接无法建立 - Postgres SSL connection failing to be established 运行 ruby​​ 服务器时出错说未建立连接 - Error while running the ruby server says connection not established 使用mysql在Rails中在ruby中创建应用程序时未建立Action Controller :: Connection - Action Controller::Connection not established while creating an application in ruby on rails with mysql 你好postgres数据库连接错误Ruby on Rails - hello postgres database connection errors Ruby on rails 在sidekiq Ruby脚本之后Postgres连接没有关闭 - Postgres connection not closing after sidekiq Ruby script Ruby On Rails Heroku Postgres数据库SSL连接 - Ruby On Rails Heroku Postgres databases SSL Connection 读取错误:# <Errno::ECONNABORTED: An established connection was aborted by the software in your host machine.> 在红宝石 - Read error: #<Errno::ECONNABORTED: An established connection was aborted by the software in your host machine.> in ruby 使用Socks Proxy的Ruby on Rails Postgres远程数据库连接 - Ruby on Rails Postgres remote database connection using Socks Proxy Rails 4:何时建立数据库连接? - Rails 4: When is a database connection established? 为什么无法建立与远程服务器的SSL连接? - Why the SSL connection to the remote server could not be established?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM