Reputation:
I've cloned a repository, and set up everything via a virtual machine loaded with Ubuntu and using RVM. Everything regarding Ruby on Rails was installed via RVM.
My issue is that, my Ubuntu login is different to the user that I assume the data base wants. Example, my Ubuntu login is Matt, but when I start rails server and load into the localhost:3000, it is saying this:
ActiveRecord::NoDatabaseError
FATAL: role "James" does not exist
I understand this is a postgres error, but what should I do now to make this work? I've search through the previous StackOverflow answers and the methods just don't work.
Eg. I've changed
local all postgres peer
to
local all postgres trust
Or using psql -h localhost -U postgres
or sudo -u postgres createuser -s $(whoami); createdb $(whoami)
and again, it doesn't work. The first command asks for a password, which I can't figure out.
Upvotes: 0
Views: 483
Reputation: 723
You can change the user Rails uses to connect to PostgreSQL by editing <project_root>/config/database.yml
(source).
Also, the reason your first psql
command didn't work is -h localhost
requires a host
entry in pg_hba.conf
, not local
. You can omit the -h localhost
for the local
entry to take effect since the default is to connect via a local socket.
Upvotes: 1