0
votes

Could anyone help me with my problem this is my first draft website?

my new question: How come my code and postgres are not connecting

I have tried of StackOverflow solutions but it just seems like I keep running into errors

This is my database.yml:

default: &default
adapter: postgresql
pool: 5
timeout: 5000

development:
    adapter: postgresql
    encoding: unicode
    database: blog_development
    pool: 5
    username: opeodumakin
    password: 6391
    port: 3000
    host: localhost

test:
    adapter: postgresql
    encoding: unicode
    database: blog_development
    pool: 5
    username: opeodumakin
    password: 6391


production:
    <<: *default
    database: db/production.sqlite3

I keep getting this error

vendor/cache/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:1013:in retrieve_connection' vendor/cache/gems/activerecord-5.2.3/lib/active_record/connection_handling.rb:118:inretrieve_connection' vendor/cache/gems/activerecord-5.2.3/lib/active_record/connection_handling.rb:90:in connection' vendor/cache/gems/activerecord-5.2.3/lib/active_record/migration.rb:554:incall' vendor/cache/gems/actionpack-5.2.3/lib/action_dispatch/middleware/callbacks.rb:28:in block in call' vendor/cache/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:98:inrun_callbacks' vendor/cache/gems/actionpack-5.2.3/lib/action_dispatch/middleware/callbacks.rb:26:in call' vendor/cache/gems/actionpack-5.2.3/lib/action_dispatch/middleware/executor.rb:14:incall' vendor/cache/gems/actionpack-5.2.3/lib/action_dispatch/middleware/debug_exceptions.rb:61:in call' vendor/cache/gems/web-console-3.7.0/lib/web_console/middleware.rb:135:incall_app' vendor/cache/gems/web-console-3.7.0/lib/web_console/middleware.rb:30:in block in call' vendor/cache/gems/web-console-3.7.0/lib/web_console/middleware.rb:20:incatch' vendor/cache/gems/web-console-3.7.0/lib/web_console/middleware.rb:20:in call' vendor/cache/gems/actionpack-5.2.3/lib/action_dispatch/middleware/show_exceptions.rb:33:incall' vendor/cache/gems/railties-5.2.3/lib/rails/rack/logger.rb:38:in call_app' vendor/cache/gems/railties-5.2.3/lib/rails/rack/logger.rb:26:inblock in call' vendor/cache/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb:71:in block in tagged' vendor/cache/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb:28:intagged' vendor/cache/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb:71:in tagged' vendor/cache/gems/railties-5.2.3/lib/rails/rack/logger.rb:26:incall' vendor/cache/gems/sprockets-rails-3.2.1/lib/sprockets/rails/quiet_assets.rb:13:in call' vendor/cache/gems/actionpack-5.2.3/lib/action_dispatch/middleware/remote_ip.rb:81:incall' vendor/cache/gems/actionpack-5.2.3/lib/action_dispatch/middleware/request_id.rb:27:in call' vendor/cache/gems/rack-2.0.7/lib/rack/method_override.rb:22:incall' vendor/cache/gems/rack-2.0.7/lib/rack/runtime.rb:22:in call' vendor/cache/gems/activesupport-5.2.3/lib/active_support/cache/strategy/local_cache_middleware.rb:29:incall' vendor/cache/gems/actionpack-5.2.3/lib/action_dispatch/middleware/executor.rb:14:in call' vendor/cache/gems/actionpack-5.2.3/lib/action_dispatch/middleware/static.rb:127:incall' vendor/cache/gems/rack-2.0.7/lib/rack/sendfile.rb:111:in call' vendor/cache/gems/railties-5.2.3/lib/rails/engine.rb:524:incall' vendor/cache/gems/puma-3.12.1/lib/puma/configuration.rb:227:in call' vendor/cache/gems/puma-3.12.1/lib/puma/server.rb:660:inhandle_request' vendor/cache/gems/puma-3.12.1/lib/puma/server.rb:474:in process_client' vendor/cache/gems/puma-3.12.1/lib/puma/server.rb:334:inblock in run' vendor/cache/gems/puma-3.12.1/lib/puma/thread_pool.rb:135:in `block in spawn_thread'

1
Did you add gem pg in Gemfile??Niraj Kaushal
yes i did add gem pgcode prodigy
Is that formatting reflective of your actual file? Indentation matters in yaml.MattMcKnight
What's the error, the "whole error" you get.Sebastian Palma
Please add the complete error you get to the question.Tobias

1 Answers

0
votes
  1. ADD

    gem 'pg', '0.18.3'
    
  2. Update your database.yml

    connection: &connection
      adapter: postgresql
      host: <%= ENV.fetch('DB_1_PORT_5432_TCP_ADDR', 'localhost') %>
      port: <%= ENV.fetch('DB_1_PORT_5432_TCP_PORT', '5432') %>
      username: postgres
      password: postgres
      pool: 5
      timeout: 5000
    
    development:
      <<: *connection
      database: development_db_name
    test:
      <<: *connection
      database: test_db_name
    
    production:
      <<: *connection
      database: production_db_name
    
  3. Restart your server