This installation process has always frustrated me and I always do something wrong. I decided to finally document it. Read more...
Pre-Requisites
- Make sure that Homebrew is installed and `brew doctor` is happy.
- Make sure rvm (or equivalent) is installed and configured.
- You know how to edit files in terminal and are comfortable using sudo.
Installation
The biggest gotcha is that by default OS X Lion comes with postgres installed already. It resides in /usr/bin which by default takes precedence over /usr/local/bin/ which is where homebrew will install postgres. To fix this edit /etc/paths to order /usr/local/bin above /usr/bin. Your file should look like this:
*Note: You'll need to use sudo to edit this file.
Install postgres using homebrew
Follow all installation instructions
Make sure you pay attention to the output after installing via homebrew. You need to make sure you've done the following before proceeding:
- Initialize the database
- Setup the server to run using launch
- Install the pg gem using the proper arguments
Verify paths are correct
*Note: If this command returns something different you may need to restart your terminal session or double check the steps above.
Create admin user
Add pg gem to Gemfile
gem 'pg'
*Note: Make sure to remove any other database adapters such as sqlite.
Add database details to the config/database.rb
*Note: my_rails_app should be the name of the user you created above.
Test & Verify
*Note: If this returns without errors then you've done everything correctly!