[英]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.