Problem getting tiny RAILS demo working

C

craig duncan

I've been following the instructions provided in
"http://darkhost.mine.nu:8080/~vince/rails/tutorial.html" to see if i
could get the basic database (Postgres)/webserver (WEBrick)/Rails
functionality working. Everything seems ok until i get to the part
where i stick "scaffold :album" into the AlbumController class.

I've got two problems. 1a) postgres ident authorization won't work for
me for a non-postgres user (nothing to do with anything but postgres) so
i just made the first line in pg_hba.conf "local all all trust" and then
(re postgres all by itself) access seems to work ok... except when i go
to "http://localhost:3000/album" i see (1b):

PGError in Album#index
FATAL: IDENT authentication failed for user "postgres"
[followed by a stack trace]

(this is with "local all all trust" as the first line in pg_hba.conf)
I'm running WEBrick as a non-postgres, non-root user.

Problem 2: I run WEBrick with -r debug and i get an exception raised in
/usr/lib/ruby/1.8/webrick/httpservlet/filehandler.rb#235:

235: st = (File::stat(res.filename) rescue nil)

(rdb:2) p res.filename
"/home/craig/Album/public/album"
(rdb:2)

Which is causing the following output (even when not running the debugger):

#<WEBrick::HTTPStatus::NotFound: `/album' not found.>
127.0.0.1 - - [31/Oct/2004:14:37:01 EST] "GET /album HTTP/1.1" 500 3657
- -> /album

There *is* no public/album directory, though. Is something wrong here?
There were no instructions to make this directory, it didn't get made
by either the new_model or new_controller scripts and (crucially) the
example cited above shows things working at this point (displaying
"Listing todos" in the tutorial).

Could my Album object be insufficiently "business"-like?
 
C

craig duncan

Vincent said:
Is config/database.yml properly configured? An authorization error
seems related to username and password. Check out
http://www.rubyonrails.org/show/TutorialStepTwo to make sure your
PostgreSQL configuration is okay.
It is. I can't figure out why ident authentication (postgres) doesn't
seem to work but when i make the first line in pg_hba.conf "host all all
trust" then every local user has access (e.g. psql <database>
postgres). database.yml specifies user "postgres". It really shouldn't
matter, though. IDENT authentication shouldn't even be being used. I'm
running ruby 1.8.2 on debian unstable, postgresql 7.4.6. I saw
something somewhere about needing to run an IDENT daemon, but could find
no verification for that idea. Anyway, as i said, IDENT authentication
shouldn't even be being used.
 
C

craig duncan

craig said:
It is. I can't figure out why ident authentication (postgres) doesn't
seem to work but when i make the first line in pg_hba.conf "host all
all trust" then every local user has access (e.g. psql <database>
postgres). database.yml specifies user "postgres". It really
shouldn't matter, though. IDENT authentication shouldn't even be
being used. I'm running ruby 1.8.2 on debian unstable, postgresql
7.4.6. I saw something somewhere about needing to run an IDENT
daemon, but could find no verification for that idea. Anyway, as i
said, IDENT authentication shouldn't even be being used.
The reason why authentication is failing is because this fails:

psql -h localhost <database> postgres

without the "-h localhost" it works fine. I can ping localhost. I
don't know why that doesn't work but that's what's keeping Rails
(activerecord) from connecting to postgres.
 
E

Eric Hodel

The reason why authentication is failing is because this fails:

psql -h localhost <database> postgres

without the "-h localhost" it works fine. I can ping localhost. I
don't know why that doesn't work but that's what's keeping Rails
(activerecord) from connecting to postgres.

I don't believe postgres accepts connections on the TCP socket by
default, only the UNIX socket. You need to edit the postgres config
files to set this up for yourself.
 
C

craig duncan

Eric said:
I don't believe postgres accepts connections on the TCP socket by
default, only the UNIX socket. You need to edit the postgres config
files to set this up for yourself.
It hadn't occurred to me that specifying localhost implied using a TCP
socket . . . but you're right. So that solves that. A note in any
documentation mentioning the role of the database.yml config file might
be in order . . . saying that if you _want_ to restrict the database to
only accept connections on UNIX sockets, then just leave the "host"
field blank.
 
T

Tobias Luetke

Please add it on the wiki where you see fit.


Eric Hodel wrote:



It hadn't occurred to me that specifying localhost implied using a TCP
socket . . . but you're right. So that solves that. A note in any
documentation mentioning the role of the database.yml config file might
be in order . . . saying that if you _want_ to restrict the database to
only accept connections on UNIX sockets, then just leave the "host"
field blank.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top