Ruby - ActiveRecord::ConnectionNotEstablished
I had the same problem, I started the sample-app from scratch and used this gemfile:
source 'http://rubygems.org'
gem 'rails', '3.1.1'
gem 'sqlite3'
group :development do
gem 'rspec-rails', '2.6.1'
end
group :test do
gem 'rspec-rails', '2.6.1'
gem 'webrat', '0.7.1'
end
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
This solved the problem for me :)
ActiveRecord::ConnectionNotEstablished randomly occured in deployed instance after migrate from Rails 5.2 to Rails 6.0
Make sure your application is not calling ActiveRecord::Base.establish_connection
manually for example, inside a health check route. Calling establish_connection
is not required as ActiveRecord establishes its own connection automatically in Rails.
When you call this method yourself, it destroys the old database connection pool and recreates another one.
[help]ActiveRecord::ConnectionNotEstablished
Try to set host: localhost
and remove socket
from database.yml
ActiveRecord::ConnectionNotEstablished (No connection pool with 'primary' found.) when rendering results
I was able to solve the issue by adding "each_serializer: nil" to render. It seems like Rails doesn't have a connection pool to 'primary' because this end point just connects to the :trmain db, but render for some reason wants to find a ActiveRecord serializer from primary.
def show
appuser_id = params[:id]
user_details = Appuser.find_user_details(appuser_id: appuser_id)
render json: user_details, status: 200, each_serializer: nil
end
Related Topics
Rails 3 Validates Inclusion of When Using a Find (How to Proc or Lambda)
Add API Key to Every Request in Activeresource
Error Occurred While Installing Mini_Racer (0.2.0)
How to Generate Coordinates in Between Two Known Points
Rails Force Models to Eager Load
Get Text Directly Inside a Tag in Nokogiri
Convert String to Class Name Without Using Eval in Ruby
Print All Method Names of a Class in Ruby
Is It Acceptable Practice to Patch Ruby's Base Classes, Such as Fixnum
How to Access Firefox Extension I Added in Selenium Webdriver
How to Use Rspec Expectations in Irb
Why Relative Path Doesn't Work in Ruby Require
Run Delayed Jobs and Sidekiq at the Same Time
Change Default Capybara Browser Window Size
Rails 3.1 Actioncontroller::Routingerror (No Route Matches [Get] "/Assets/Rails.Png"):