Linux to Mac

Installing Ruby on Rails and PostgreSQL on Leopard

- 2008.02.15 - Tip Jar

Popularity: LEMLEMLEMLEM

del.icio.us Bookmark in del.icio.us

Low End Mac Reader Specials

Memory To Go Special: MacPro 8 Core Memory 4GB kit $154 / 2GB kit $94, New 2008 iMac 2GB $46. MacBook Pro / MacMini / iMac Intel Core2 DUO 2GB $44 / 1GB $23--Free shipping available.

Download Typestyler, still the Ultimate Styling Tool for Internet, Print and Video Graphics. Works great in Classic with a Native OS X Version on the way. Free Tryout: www.typestyler.com

LA Computer Company: LA Computer Company: Specials on AppleCare, Apple Displays, MacBooks, iMac's, MacBook Pros, Laptop and iPod accessories and more. Apple A/C Adapters for laptops starting at $25.00 Call 1-800-941-7654 or Click Here.

OWC: NewerTech miniStack FireWire/USB 2.0 HD & Hub Up to 1.0TB of Performance Storage + FW/USB2 Powered Hubs - convenient & sleek 6.5" x 6.5" x 1.5" Featured: 500GB $169.99; 750GB $209.99; 1.0TB $339.99

Mac users can finally play Party Poker for Mac. Not only that, they can also learn how to play PokerStars for Mac.

Laptop Hardware Provided by TechRestore - Overnight Mac & iPod Repairs.

Compare products like desktop computers, laptops, and LCD TVs side by side! All the information and reviews to make the best purchasing decision for a new cell phone GPS products or MP3 players. The Ciao network makes searching products easy for you.

MacPro Memory 667Mhz With Apple Spec Heat Sink 2GB $90 / 4GB $134 / 8GB $264. Click to Maximize your Macs...

Setting up a development environment with Ruby on Rails and the PostgreSQL database on Leopard is straightforward. In an interesting twist, the hard part of setting up Rails and PostgreSQL on OS X 10.5 "Leopard" is easy with Linux, and the easy part is hard with Linux.

Rails, the Easy Part

If you haven't heard, Ruby on Rails is a web development framework created by David Heinemeier Hansson that uses the Model-View-Controller (MVC) design pattern for separating business logic from the presentation details. The MVC approach is very popular in enterprise class systems.

Apple recognized the momentum behind Rails and includes a basic configuration by default. The Ruby language (1.8.6) is installed along with the Rails (1.2.3) framework. In addition to the Ruby language and Rails, OS X Leopard includes a number of useful supporting packages (called Ruby Gems). This saves you the setup time for the basic infrastructure that is required on most Linux distributions.

PostgreSQL, the Hard Part

In order to get the PostgreSQL database up and running on Leopard, use MacPorts to install it. To use MacPorts, you first need to install the X-code tools from the Leopard DVD. It's an optional install, but you need the compiler and supporting libraries to compile and install PostgreSQL. (Most Linux distributions have precompiled PostgreSQL packages ready to install with one command, making this part of the set up easier on Linux.)

Once MacPorts is installed, install PostgreSQL with:

sudo port install postgresql83

It takes quite a while for MacPorts to download and compile PostgreSQL. It took about 90 minutes for me. After it's installed, there are a couple of post install commands that need to be run so that it starts automatically at boot time. The commands are described in detail once MacPorts finishes the basic installation.

Install the Ruby PostgreSQL Driver

In a production environment, you need the latest native PostgreSQL binary driver. I tried a couple of times to install the binary driver on my iBook, but I kept getting compile errors. I got around the problem by installing the "pure ruby" driver (indicated by the -pr suffix):

sudo gem install postgres-pr

I haven't noticed a performance issue during development, but I would not feel comfortable using it for a production application.

Telling Rails to Use PostgreSQL

The final step after starting a new Rails application is to modify the "config/database.yml" file to tell Rails to use PostgreSQL. Here is an example:

development:
  adapter: postgresql
  database: keithw
  username: keithw

Having Ruby and the basic Rails environment available out of the box is a huge plus for OS X Leopard.  LEM

Keith Winston is a recent Mac convert after five years of Linux on the desktop. He also writes for Linux.com and recently created CommandLineMac.com to focus on the Unix-y power of the Mac. If you find Keith's articles helpful, please consider making a donation to his tip jar.

Recent Linux to Mac Columns

Recent Content on Low End Mac

About LEM | Support | Usage | Privacy | Contacts


Have a question?
Ask an expert!

Low End Living

Amazon.com

Navigation

Used Mac Dealers
Apple History
Best Used Macs
Video Cards
Email Lists
InfoMac's Low
End Mac Forum

Favorite Sites

MacSurfer
MacMinute
MacInTouch
MyAppleMenu
InfoMac
Macs Only!
The Mac Observer
Accelerate Your Mac
RetroMacCast
PB Central
MacWindows
The Vintage Mac
   Museum

DealMac
DealsOnTheWeb
Mac2Sell
ramseeker
Mac Driver Museum
JAG's House
System 6 Heaven
System 7 Today
the pickle's Low-End
   Mac FAQ

Abandonware
   Petition

Mac vs. PC Info

Affiliates

The Apple Store
Mac Connection
MacMall
TechRestore
MacResQ
ExperCom
Crucial Memory
batteries.com

Advertise

Open Link