No connection pool for ActiveRecord :: Base

I am trying to use rails 4.2.6 for application development. I am trying to use postgres for a database. The server starts normally, but when I try to load the page, it generates this error "There is no connection pool for ActiveRecord :: Base".

What could it be?

EDIT

The pg gem did not work properly. I had to comment on this before starting the server, and then uncomment it from my GemFile. I realized that I used Ruby 2.3 instead of Ruby 2.0 (as expected). I uninstalled ruby ​​2.3 and configured everything under Ruby 2.0. Now it works correctly.

I read somewhere that there were problems with the "pg" gem in new Rails releases, requiring people to use the "gem install pg -pre" instead to install the gem. I tried this, but then my application required the pg pearl in my GemFile, and, well, the problem outlined above appeared again.

This is how my database.yml file ended:

default: &default adapter: postgresql encoding: unicode host: localhost username: ------- password: ------- pool: 5 development: <<: *default database: myDbName 
+9
source share
8 answers

If you encounter this error from a rake task, most likely you are not completing the task :environment in front of your task.

The change:

 task :task_name do end 

in

 task task_name: :environment do end 

Need to fix the problem.

+24
source

This problem occurs when the server cannot find the appropriate database on which the receipt of data depends.

I had the same problem on my part, I updated my version of Sqlite3, and it was higher than the version supported by the current version of Puma Server.

I just had to uninstall the version of Sqlite3, and then install the version supported by the current version of Puma Server.

 gem uninstall sqlite3 

This will remove the updated version of Sqlite3, and then you will run the code below indicating the version supported by your current server.

 gem install sqlite3 

Or you can also open your Gemfile and then enable the version for the database you are using

 gem 'sqlite3', '~> 1.3.6' 

N / B: sqlite3 version is the latest version at the time of writing this answer

And then run

 bundle update 

Install the version of the database that you specified.

All this.

Hope this helps.

+5
source

Check database.yml if all settings are ok. If for the first time you did not create a database, use this command to create a database

 rake db:create 

If the database already exists, try resetting the db migration,

 rake db:migrate:reset 

Hope this solves the problem. Go to the rails console and try something to check if it works or not.

+3
source

For PostgreSQL, your database.yml file should look something like this:

 default: &default adapter: postgresql encoding: unicode # For details on connection pooling, see rails configuration guide # http://guides.rubyonrails.org/configuring.html#database-pooling pool: 5 development: <<: *default database: your_db_name 

Also make sure you have gem: installed in your Gemfile:

 gem 'pg' 

Finally, reboot the server.

Hope that helps

Edit: I almost forgot, make sure PostgresSQL is working for you, check this link for download and configuration.

+2
source

I encountered the same problem when I try to access the model before creating the database.

Be sure to run rake db:migrate at least once.

If you are already migrating, check the database as indicated in previous answers.

0
source

Rails 5

New app

Using Postgresql for testing and development

Functions are launched, so Rails can connect to Postgresql

But when I started the web application, I got "No connection pool with primary found identifier."

Ran 'bin / rails db: migrate: reset' and restarted the application. It worked. I do not know why.

database.yml:

  development: adapter: postgresql encoding: unicode database: rails5_development pool: 5 username: foo password: bar host: localhost port: 5432 test: adapter: postgresql encoding: unicode database: rails5_test pool: 5 username: foo password: bar host: localhost port: 5432 
0
source

I just had to restart the server so that the warning disappears.

0
source

when you run rails db:migrate in the database, the rows will be created according to your migration files. You can see the diagram for more information.

0
source

All Articles