Forum: Ruby on Rails Postgres - how to connect?

827750524d7a5cb7fca68b1bf133cb4d?d=identicon&s=25 Pawel Stawicki (amorfis)
on 2007-11-22 10:05
I am trying to connect to postgres database from RoR. I have username
and password in database.yml, but when trying to connect, I get the
following error:

No such file or directory - /tmp/.s.PGSQL.5432

Why is it? I would also prefer to connect by TCP connection instead of
UNIX socket, how can I configure this?

Thanks in advance
Paweł Stawicki
2d532341317628fbb2cb22ec427a1d62?d=identicon&s=25 Stefan Lang (Guest)
on 2007-11-22 12:28
(Received via mailing list)
On 22 Nov., 10:05, Pawel Stawicki <rails-mailing-l...@andreas-s.net>
wrote:
> I am trying to connect to postgres database from RoR. I have username
> and password in database.yml, but when trying to connect, I get the
> following error:
>
> No such file or directory - /tmp/.s.PGSQL.5432
>
> Why is it? I would also prefer to connect by TCP connection instead of
> UNIX socket, how can I configure this?

I remember having the same problem, but I don't remember
the details anymore. Anyway, here's my current database.yml:

  production:
    adapter: postgresql
    database: foo_production
    username: postgres
    password: secret
    host: localhost
    encoding: UTF8

Similar for test and development, _no_ other settings.
(Especially, I think there was a "port" setting that needed to
be removed.)

HTH,
  Stefan
Bfd12b41ba8ebd4a02a35df24de6ef09?d=identicon&s=25 Piet Hadermann (piethadermann)
on 2007-11-22 15:25
Pawel Stawicki wrote:
> I am trying to connect to postgres database from RoR. I have username
> and password in database.yml, but when trying to connect, I get the
> following error:
>
> No such file or directory - /tmp/.s.PGSQL.5432
>
> Why is it? I would also prefer to connect by TCP connection instead of
> UNIX socket, how can I configure this?
>

Check under 'connections and authentication' in data/postgresql.conf to
see if you're listening on the connect ip-adresses (or listening on ip
at all).
You might also need to adapt data/pg_hba.conf to enable local access
with the account you're using.

My database.yml looks like the one Stefan Lang posted.

Piet.
827750524d7a5cb7fca68b1bf133cb4d?d=identicon&s=25 Pawel Stawicki (amorfis)
on 2007-11-22 15:42
> Check under 'connections and authentication' in data/postgresql.conf to
> see if you're listening on the connect ip-adresses (or listening on ip
> at all).

I am. I can connect by phpphadmin (web php tool) with user and password
without problems. But it seems to me that ruby tries to connect by
socket, not by TCP/IP, and I don't like this.

Regards
Pawel Stawicki
827750524d7a5cb7fca68b1bf133cb4d?d=identicon&s=25 Pawel Stawicki (amorfis)
on 2007-11-22 15:44
Sorry, didn't notice the first answer. I will try removing "port".

Regards
Paweł Stawicki
827750524d7a5cb7fca68b1bf133cb4d?d=identicon&s=25 Pawel Stawicki (amorfis)
on 2007-11-22 22:53
Ok, it worked, but now I got next error. I have table "Article", and I
created model Article, but when I try to run test (just to test
connection), I get "Exception: RuntimeError: ERROR C42P01 Mrelation
"article" does not exist Fnamespace.c L221 RRangeVarGetRelid: DELETE
FROM article"

My table has name beginning with capital letter, but I think I doesn't
matter, because when I had changed it, I still was getting the error.

Regards
Paweł Stawicki
A05e94932701f67ef57a38d834e74054?d=identicon&s=25 Scott Woods (woods)
on 2009-04-07 15:59
Pawel Stawicki wrote:
> My table has name beginning with capital letter, but I think I doesn't
> matter, because when I had changed it, I still was getting the error.

I know the parent post is from a long time ago, but it turns out that
this is a bug in the rails postgresql adapter -- it doesn't support
table names with capital letters. There's a ticket and patch here:

https://rails.lighthouseapp.com/projects/8994-ruby...

If anyone could verify this patch, it would be much appreciated.

Thanks,
Scott
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.