class << self def call(*arg) new(*arg).constructor end end attr_reader :result def constructor @result = call self end
production: <<: *default url: postgresql-makara:/// makara: sticky: true connections: - role: master name: primary url: <%= ENV["DATABASE_URL"] %> - name: replica url: <%= ENV["ANALYTICS_URL"] %>
default: &default adapter: postgresql encoding: unicode development: primary: <<: *default database: hot_seller_development follower: <<: *default database: hot_seller_development replica: true production: primary: <<: *default url: <%= ENV['DATABASE_URL'] %> follower: <<: *default url: <%= ENV['ANALYTICS_URL'] %> replica: true
ActiveRecord::Base.establish_connection(Rails.application.credentials.fetch :DATABASE_URL)
# config.active_record.database_selector = { delay: 2.seconds } I am not using this line so all the db connections should all go to db-w...
self.abstract_class = true connects_to database: { writing: :primary, reading: :follower }