1

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

2
  • I can save the model through active record. Its just when it is called through a rake task that it fails. Commented Nov 14, 2013 at 15:39
  • SOLUTION: I needed to set the environment to task :import => :environment do That way it can see the DB Commented Nov 14, 2013 at 15:45

1 Answer 1

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?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.