# PostgreSQL, postgres gem, rails2.pdf, http://ruby.scripting

**URL:** <https://www.ruby-forum.com/t/postgresql-postgres-gem-rails2-pdf-http-ruby-scripting/100651>\
**Category:** Rails\
**Created:** [July 31, 2006, 4:17am UTC](https://www.ruby-forum.com/t/postgresql-postgres-gem-rails2-pdf-http-ruby-scripting/100651 "2006-07-31T04:17:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bikle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9e8a1a/32.png) [@bikle](https://www.ruby-forum.com/u/bikle)\
**Post date:** [July 31, 2006, 4:17am UTC](https://www.ruby-forum.com/t/postgresql-postgres-gem-rails2-pdf-http-ruby-scripting/100651/1 "2006-07-31T04:17:35Z")

</div>

Hello people…

In the rails2.pdf Dave T says:

Rails works with the DB2, MySQL, Oracle, Postgres,…

The database drivers are all written in C and are primarily distributed  
in  
source form.

Then he lists this site:  
[http://ruby.scripting.ca/postgres/](http://ruby.scripting.ca/postgres/)

Then he says,

There is a pure-Ruby version of the Postgres adapter available. Download  
postgres-pr from the Ruby-DBI page at  
[http://rubyforge.org/projects/ruby-dbi](http://rubyforge.org/projects/ruby-dbi)

So I understand all this and I’m happy.

But then I bumped into this page:

[http://www.robbyonrails.com/articles/2006/05/29/install-ruby-rails-and-postgresql-on-osx](http://www.robbyonrails.com/articles/2006/05/29/install-ruby-rails-and-postgresql-on-osx)

It suggests that I install a gem using a command line like this:

gem install postgres

So, I tried it and it installed okay.

I then rails a tmp\_app and edited my database.yml

I tested with…

rake db:migrate

It ran fine.

I should be happy but I’m not.  
Actually I’m happy that I can now do development.

But…  
I’m not sure how rails is connected to my PostgreSQL database.

Q1: What is the best way to connect Rails to PostgreSQL in a Production  
environment?

Q2: For Production, should I use the postgres gem?

Q3: The software here: [http://ruby.scripting.ca/postgres/](http://ruby.scripting.ca/postgres/) …  
Should I try to figure out how to make it serve as a layer between  
my  
Rails app  
and PostgreSQL? Or, should I ignore it?

-Dan

---

<div class="post-metadata">

**Author:** ![bikle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9e8a1a/32.png) [@bikle](https://www.ruby-forum.com/u/bikle)\
**Post date:** [July 31, 2006, 4:38am UTC](https://www.ruby-forum.com/t/postgresql-postgres-gem-rails2-pdf-http-ruby-scripting/100651/2 "2006-07-31T04:38:57Z")

</div>

Hi Again,

I looked here:

ruby/gems/1.8/gems/postgres-0.7.1/README

It appears to me that the gem is a wrapper for the code here:

[http://ruby.scripting.ca/postgres/](http://ruby.scripting.ca/postgres/)

So, to answer my own questions:

Q1: What is the best way to connect Rails to PostgreSQL in a Production  
environment?  
A: Use the gem

Q2: For Production, should I use the postgres gem?  
A: Yes

Q3: The software here: [http://ruby.scripting.ca/postgres/](http://ruby.scripting.ca/postgres/) …  
Should I try to figure out how to make it serve as a layer between  
my  
Rails app  
and PostgreSQL? Or, should I ignore it?  
A: Ignore it

-Dan

---

<div class="post-metadata">

**Author:** ![bikle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9e8a1a/32.png) [@bikle](https://www.ruby-forum.com/u/bikle)\
**Post date:** [August 8, 2006, 6:57am UTC](https://www.ruby-forum.com/t/postgresql-postgres-gem-rails2-pdf-http-ruby-scripting/100651/3 "2006-08-08T06:57:54Z")

</div>

Dan B. wrote:

> Hi Again,
> 
> I looked here:
> 
> ruby/gems/1.8/gems/postgres-0.7.1/README
> 
> It appears to me that the gem is a wrapper for the code here:
> 
> [http://ruby.scripting.ca/postgres/](http://ruby.scripting.ca/postgres/)
> 
> So, to answer my own questions:
> 
> Q1: What is the best way to connect Rails to PostgreSQL in a Production  
> environment?  
> A: Use the gem
> 
> Q2: For Production, should I use the postgres gem?  
> A: Yes
> 
> Q3: The software here: [http://ruby.scripting.ca/postgres/](http://ruby.scripting.ca/postgres/) …  
> Should I try to figure out how to make it serve as a layer between  
> my  
> Rails app  
> and PostgreSQL? Or, should I ignore it?  
> A: Ignore it
> 
> -Dan

Hi All,

I am a newbie in Ruby-Rails. Actually we are using postgre SQL and Ruby  
application to access the DB. I have made the controller and the model  
classes. My database.yml contains:

development:  
adapter: postgresql  
database: test  
username: poc  
password: poc  
host: localhost:5000

test:  
adapter: postgresql  
database: test  
username: poc  
password: poc  
host: localhost:5000

production:  
adapter: postgresql  
database: test  
username: poc  
password: poc  
host: localhost:5000

I have actually configured my postgresql to listen to port 5000 rather  
than 5432(default). When I hit the url [http://127.0.0.1:3000/Testing/new](http://127.0.0.1:3000/Testing/new)  
it is showing an error:

Bad file descriptor - connect(2)

My model → testing.rb

class Testing \< ActiveRecord::Base

end

My Controller → testing\_controller.rb

class TestingController \< ApplicationController  
scaffold :testing  
end

How can I resolve this problem… Thanks in advance…

Regards,  
Janeve

---

<div class="post-metadata">

**Author:** ![bikle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9e8a1a/32.png) [@bikle](https://www.ruby-forum.com/u/bikle)\
**Post date:** [August 8, 2006, 5:18pm UTC](https://www.ruby-forum.com/t/postgresql-postgres-gem-rails2-pdf-http-ruby-scripting/100651/4 "2006-08-08T17:18:06Z")

</div>

Janeve George \<janeve\_reckoner@…\> writes:

> password: poc  
> host: localhost:5000

> How can I resolve this problem… Thanks in advance…

These are the comments that used to be in the default database.yml  
file… not  
sure whose donkey idea was it to remove all this stuff? 🙂 Anyway  
maybe it  
will help you:

# Connect on a TCP socket. Omitted by default since the client uses a

# domain socket that doesn’t need configuration.

#host: remote-database  
#port: 5432

Robert Treat
