Jonathan Reiser
Jonathan Reiser

Reputation: 45

Could not create database in rails. "ActiveRecord::NoDatabaseError: FATAL: role "jonathanreiser" does not exist"

I am attempting to create a database for a Rails application and I get the following error message ActiveRecord::NoDatabaseError: FATAL: role "jonathanreiser" does not exist. I am running Postgres 9.6 on OS X El Capitan, Version 10.11.15.

I saw there were similar questions on StackOverflow, but I tried implementing their answers with no success. For example, sudo -u postgres createuser jonathanreiser or sudo su - postgres does not work. Any help would be appreciated.

Upvotes: 0

Views: 2371

Answers (2)

Roger Perez
Roger Perez

Reputation: 3139

Run

rails db:create

or

rake db:create

Then you can run rails db:migrate

Upvotes: 1

puneet18
puneet18

Reputation: 4427

Configure database.yml with below code:

default: &default

adapter: postgresql
  pool: 5
  timeout: 5000
  username : username //pg username
  password : password //pg password

development:
  <<: *default
  database: db_name

test:
  <<: *default
  database: db_name

production:
  <<: *default
  database: db_name

then run command to create database:

rake db:create

Upvotes: 2

Related Questions