在OSX上安装PostgreSQL进行Rails开发 [英] Installing PostgreSQL on OSX for Rails development

查看:82
本文介绍了在OSX上安装PostgreSQL进行Rails开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去几天中,我花了几个小时试图让PostgreSQL在Mac上与RoR配合使用。

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

我已经使用了几本教程,不同的方法,例如手动安装PostgreSQL以及通过各种一键式安装程序进行安装

I've followed several tutorials using several different methods such as installing PostgreSQL manually and installing from various 1-click installers

但是,我尝试的所有不同方法在安装pg gem的最后一步都失败了。

However the all the different methods I tried failed on the last step of installing the pg gem. Very frustrating!

这里是否有人有经过实践检验的教程来完成此任务? (或者您想在这里写一些说明...?)

Does anyone here have a tried and tested tutorial for getting this done? (Or would you like to write some instructions here...?)

我的环境是这样的:运行OSX 10.6的Macbook,PostgreSQL 8.4.1服务器

My environment is this: Macbook running OSX 10.6, PostgreSQL 8.4.1 server

推荐答案

我认为我已经找到了一种可行的方法。我从此好文章中大量借用 1 ,但是由于他们同时安装了许多其他内容,因此我将在这里为那些正在寻找PostgreSQL安装答案的人写下我所做的事情。

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 编者注:尝试时链接似乎已死。是这个吗? http://blog.blackwhale.at/?p=175#PostgreSQL


  1. 下载 PostgreSQL for Mac ,然后下载 Postgres.app安装程序。

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

创建用户为您的Rails开发(请记住,如果您在开发过程中共享一个应用程序,则可能会希望开发团队的所有成员之间使用同一用户,以避免出现头痛)

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


  • 输入您的Mac OS X系统用户名作为角色名称,并使其成为超级用户。

  • Enter your Mac OS X system user name as role name, and make it a superuser.

    安装pg gem,以便Rails可以进行交谈到PostgreSQL

    Install the pg gem so Rails can talk to PostgreSQL

    sudo env PATH=/Library/PostgreSQL8/bin:$PATH gem install pg
    


  • 配置您的rails应用程序与Po对话stgreSQL。您可以使用以下命令创建新应用程序:

  • 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)
    

    或者对于现有应用,修改您的数据库.yml 文件。

    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.

    这篇关于在OSX上安装PostgreSQL进行Rails开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆