Verifying Good Setup of RoR + PostgreSQL

I’ve been reading the RoR tutorials and wiki help stuff, but I’m stuck.
:frowning:

I’ve got RoR installed properly and get the “Welcome aboard! You’re
riding the rails.” I have an “article” controller, “article” model, and
both an “article” and “articles” views (one is a remnant, I think, and
no longer needed) (the “article” folder is empty, but “articles”
contains “edit.rhtml” and others). Does that sound workable so far?

I also have a PostgreSQL database set up called MMC, with one table
called articles, with columns of id, title, blurb, author.

How do I test this configuration?

http://MMC works fine.
http://MMC/article gives me the error message:

Errno::EINVAL in ArticleController#index

Invalid argument

When I run rake, I get the following errors. Can somebody please let me
know what I can do to fix them? Thanks!

  1. Error:
    test_truth(ArticleControllerTest):
    NameError: uninitialized constant PGconn

  2. Error:
    test_truth(ArticleControllerTest):
    NameError: uninitialized constant ActiveRecord::PGconn

Thanks!

On May 11, 2006, at 10:27 AM, c.k.lester wrote:

I also have a PostgreSQL database set up called MMC, with one table
called articles, with columns of id, title, blurb, author.

How do I test this configuration?

http://MMC works fine.
http://MMC/article gives me the error message:

Errno::EINVAL in ArticleController#index

Is it safe to assume that you have a model called Article?

If so… try this from the terminal/console.

ruby script/console
(wait for console to load…)

Article.count

What happens?

Robby


Robby R.
Founder & Executive Director

PLANET ARGON, LLC
Ruby on Rails Development, Consulting & Hosting

www.robbyonrails.com

+1 503 445 2457
+1 877 55 ARGON [toll free]
+1 815 642 4968 [fax]

I’m wondering have you set up your database.yaml file in the config
directory of your rails app?

You should change the name of the database to match the one that your
using,
also provide the username and password for access to the database here.

Robby R. wrote:

called articles, with columns of id, title, blurb, author.

How do I test this configuration?

http://MMC works fine.
http://MMC/article gives me the error message:

Errno::EINVAL in ArticleController#index

Is it safe to assume that you have a model called Article?

Yes. article.rb in the models folder.

If so… try this from the terminal/console.

ruby script/console
(wait for console to load…)

Article.count

What happens?

Error message as follows:

NameError: uninitialized constant PGconn
from
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active-support/dependencies.rb:123:in
‘const_missing’

Daniel N wrote:

I’m wondering have you set up your database.yaml file in the config
directory of your rails app?

You should change the name of the database to match the one that your
using, also provide the username and password for access to the
database here.

Yes, I’ve done that. Here it is, sans my password…

(Oh, one thing… my database is called mmc.)

MySQL (default setup). Versions 4.1 and 5.0 are recommended.

Install the MySQL driver:

gem install mysql

On MacOS X:

gem install mysql – --include=/usr/local/lib

On Windows:

There is no gem for Windows. Install mysql.so from RubyForApache.

http://rubyforge.org/projects/rubyforapache

And be sure to use new-style password hashing:

http://dev.mysql.com/doc/refman/5.0/en/old-client.html

development:
adapter: postgresql
database: mmc_development
username: postgres
password: ***
host: localhost

Warning: The database defined as ‘test’ will be erased and

re-generated from your development database when you run ‘rake’.

Do not set this db to the same as development or production.

test:
adapter: postgresql
database: mmc_test
username: postgres
password: ***
host: localhost

production:
adapter: postgresql
database: mmc_production
username: postgres
password: ***
host: localhost

Jim Hughes wrote:

Looks to me like the “uninitialized constant” is the postgres
connection class. Do you have the postgres gems installed? I’ve
never used postgres with rails, so I can’t really advise you on
setting it up.

Yes. The last one I loaded was ‘gem install ruby-postgres’ the one they
say to use but could be buggy. but i was also using one before that that
didn’t seem to work either. :confused:

You said your database was call mmc but in your database.yaml you have
the
development database called mmc_development

Looks to me like the “uninitialized constant” is the postgres
connection class. Do you have the postgres gems installed? I’ve
never used postgres with rails, so I can’t really advise you on
setting it up.

Daniel N wrote:

You said your database was call mmc but in your database.yaml you have
the development database called mmc_development

I was wondering if that mattered… let me check it out. :slight_smile:

Daniel N wrote:

You said your database was call mmc but in your database.yaml you have
the development database called mmc_development

well, it didn’t seem to matter. i rebooted WEBrick and it still gives me
the same error. :confused:

C. K. Lester wrote:

When I run rake, I get the following errors. Can somebody please let me
know what I can do to fix them? Thanks!

  1. Error:
    test_truth(ArticleControllerTest):
    NameError: uninitialized constant PGconn

  2. Error:
    test_truth(ArticleControllerTest):
    NameError: uninitialized constant ActiveRecord::PGconn

Thanks!

It may be because you have an initializer in /config/initializers like:

def PGconn.quote_ident(name)
%("#{name}")
end

Look in the entire project for: pgconn