Rails with Postgresql

Wednesday, June 29 2005 @ 10:02 AM BST

Contributed by: robin

My first attempts at using Rails with MySQL weren't all that successful - I'm not sure why. However, as I intend to use Postresql in the long run, I decided to install the Rails Postgresql adapter.

First, I installed the ruby-devel package (needed to build gems packages).

# yum install ruby-devel

Now instal the postgres driver for Rails:

# gem install postgres --remote

I then started to run through the tutorial on the RubyOnRails Wiki.

I created a Postgres database "rails_development" and a postgres user "rails"

I ran the script to create the "people" table.

Created a new Rails app called "WikiDemo" and made it available at http://rails.robinbowes.com

Modified config/database.yml to point to the newly created postgres database:

development:
  adapter: postgresql
  database: rails_development
  host: localhost
  username: rails
  password: secret

Created a new Controller:

# ./script/generate controller Friends list show new

Created a new Model:

# ./script/generate model Person

Edited the display code:

vi app/views/friends/show.rhtml

Edited the model:

vi app/controllers/friends_controller.rb

Browsed to the site to see if it worked:

http://rails.robinbowes.com/friends/show

Bah, it didn't!

Comments (2)


robinbowes.com
http://robinbowes.com/article.php/20050629100224279