Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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. In the rake task it takes Class2 and does a create. 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. IE if I save a user, it works as expected and if I save a car, it fails. The classes are identical.

I am using ruby on rails and postgres

share|improve this question
    
I can save the model through active record. Its just when it is called through a rake task that it fails. –  Jonathan O Nov 14 '13 at 15:39
    
SOLUTION: I needed to set the environment to task :import => :environment do That way it can see the DB –  Jonathan O Nov 14 '13 at 15:45

1 Answer 1

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.

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?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.