Installing PostgreSQL on OSX for Rails development

前端 未结 6 1298
南笙
南笙 2021-01-30 07:30

I\'ve spent several hours over the past few days trying to get PostgreSQL to play nice with RoR on my Mac.

I\'ve followed several tutorials using several different metho

6条回答
  •  孤独总比滥情好
    2021-01-30 08:12

    I think I've managed to find a way that works. I'm borrowing heavily from this great post1, but since they are installing a bunch of other stuff at the same time I'm going to write out what I did here for people who are just looking for the PostgreSQL install answer.

    1 Editor's note: Link seemed dead when I tried. Is this the one? http://blog.blackwhale.at/?p=175#PostgreSQL Please fix if it is.

    1. Download PostgreSQL for Mac and download the ‘Postgres.app’ installer.

    2. Create a user for your rails development (keep in mind that if you're sharing an application during development you'll probably want the same user between all members your dev team in order to avoid headaches)

      sudo -u postgres /Library/PostgreSQL8/bin/createuser
      
    3. Enter your Mac OS X system user name as role name, and make it a superuser.

    4. Install the pg gem so Rails can talk to PostgreSQL

      sudo env PATH=/Library/PostgreSQL8/bin:$PATH gem install pg
      
    5. Configure your rails app to talk to PostgreSQL. You can either create a new application with:

      rails *appname* -d postgresql (for Rails 3 -> rails new *appname* -d postgresql)
      

      Or for an existing app, modify your database.yml file.

    This worked for me without any hiccups. If anyone else tries using this method I'd be interested to hear some feedback on how it went for you.

提交回复
热议问题