Making the database.yml file work in Rails on OSX

匿名 (未验证) 提交于 2019-12-03 03:06:01

问题:

I understand that using postgres on osx is a little difficult because it has its own version running, and so in order to psql to it you need to supply the host name like so

psql -h localhost mydatabasename -U me

However how do you do this for your database.yml file for all the rail loveliness.

If you try to connect with

development:   adapter: postgresql   username: me   database: mydatabasename 

you receive the classic

Couldn't create database for {"adapter"=>"postgresql", "username"=>"me", "database"=>"mydatabasename"} could not connect to server: No such file or directory     Is the server running locally and accepting     connections on Unix domain socket "/tmp/.s.PGSQL.5432"? 

Any ideas on how to supply the information or config osx not to suck so much?!

回答1:

If you're able to connect to Postgres on localhost with psql, then just add:

 host: localhost 

to the database.yml



回答2:

My working configuration is as follows:

development:     adapter: postgresql     database: database_name     host: localhost     username: user_name     pool: 5     timeout: 5000 

So I suppose you need to add host: localhost.



回答3:

 development:   adapter: postgresql   encoding: utf8   database: name   username: hading   password: my_db_password   host: localhost # not mandatory   pool: 5 # not mandatory   timeout: 5000 # not mandatory 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!