skip to Main Content

I need to create rails app with nginx and puma. I followed this guide: https://www.codeflow.site/fr/article/how-to-deploy-a-rails-app-with-puma-and-nginx-on-ubuntu-14-04.

but this line doesn’t work as expected:

RAILS_ENV=production rake db:create

it drops the following error:

** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Execute db:create
no implicit conversion of nil into String
Couldn't create '' database. Please check your configuration.
rake aborted!
TypeError: no implicit conversion of nil into String
[...]
Tasks: TOP => db:create

Here is the content of my database.yml file:

# SQLite. Versions 3.8.0 and up are supported.
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
#
default: &default
  adapter: sqlite3
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

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

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.

    test:
      <<: *default
      database: db/test.sqlite3
    
    production:
     <<: *default
     host: localhost
     adapter: postgresql
     encoding: utf8
     database:
     pool: 5
     username: user
     password: mdp

2

Answers


  1. can you check config/database.yml file production database name

    Must be this way

    production:
      <<: *default
      database: app_production
    
    Login or Signup to reply.
  2. All environments must use same database adapter

    Sample database.yml file for PostgreSQL. Can you check configuration for this

    # PostgreSQL. Versions 9.1 and up are supported.
    #
    # Install the pg driver:
    #   gem install pg
    # On OS X with Homebrew:
    #   gem install pg -- --with-pg-config=/usr/local/bin/pg_config
    # On OS X with MacPorts:
    #   gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
    # On Windows:
    #   gem install pg
    #       Choose the win32 build.
    #       Install PostgreSQL and put its /bin directory on your path.
    #
    # Configure Using Gemfile
    # gem 'pg'
    #
    default: &default
      adapter: postgresql
      encoding: unicode
      host: localhost
      pool: <%= ENV.fetch("DB_POOL_SIZE") { 15 } %>
    
    development:
      <<: *default
      database: myapp_development
    
    
    test:
      <<: *default
      database: myapp_test
    
    # As with config/secrets.yml, you never want to store sensitive information,
    # like your database password, in your source code. If your source code is
    # ever seen by anyone, they now have access to your database.
    #
    # Instead, provide the password as a unix environment variable when you boot
    # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
    # for a full rundown on how to provide these environment variables in a
    # production deployment.
    #
    # On Heroku and other platform providers, you may have a full connection URL
    # available as an environment variable. For example:
    #
    #   DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
    #
    # You can use this database configuration with:
    #
    #   production:
    #     url: <%= ENV['DATABASE_URL'] %>
    #
    production:
      <<: *default
      username: user
      password: mdp
      database: myapp_production
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search