Rails on Leopard (The right way)

Sunday, January 6th, 2008

My last tutorial has caused some people a few headaches, mainly due to mysql not installing properly and because it was using macports ruby and rubygems were recompiled and meant all your gems had to be installed too.

But there is a better way, since the release of Ruby on Rails 2.0.2, sqlite3 has become the default database for rails. Although I wouldn’t use sqlite3 in production it works great for development and testing on Leopard.

To set it up on a fresh install of leopard you only need on command:

sudo gem update

That should update rails to 2.0.2 and some other gems and you get started on rails so much quicker!

To update your existing rails apps to work with sqlite3 change your database.yml file to look like this pastie.

If your not on Leopard you can still use sqlite3 by installing the gem:

sudo gem install sqlite3-ruby

7 Comments so far »

  1. […] Update: Since Rails 2.0.2 has been released rails setup on leopard has been greatly simplified, check out my new guide here: teabass.com/rails-on-leopard-the-right-way […]

    Teabass - Andrew Nesbitt's Blog » Super Simple Ruby on Rails Install with MacPorts (for Leopard) on January 6, 2008 5:29 pm

  2. What the Heck is “Ruby on Rails”?

    Mike Kaufmann on January 7, 2008 12:19 pm

  3. I’m unconvinced giving up installing MySQL is “The right way.”

    Can anyone point me to the solution to the macports mysql errors a lot of us are getting. i.e.

    ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/opt/local/var/run/mysql5/mysqld.sock’ (38)

    Robert Head on January 7, 2008 9:10 pm

  4. Robert: “ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/opt/local/var/run/mysql5/mysqld.sock’ (38)”

    Usually this is caused when the default socket location for mysql taken by AR is incorrect OR mysql is offline. Find the new socket location (from /opt/local and /usr/local run “find . -name “*.sock” to see where it is) or make sure mysql is up with sudo mysqld start

    Corey M on January 14, 2008 4:04 pm

  5. Hey, this is great. The official Rails site is out of date - and I have been trying to install Rails on Leopard… Thanks a million for this.

    byronbay on February 7, 2008 3:10 am

  6. obert: “ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/opt/local/var/run/mysql5/mysqld.sock’ (38)” is a well known bug that I ran into at one point. I found a fix for it but that was a long time ago. Google around and if your google-fu is good enough, you’ll find a page with instructions on symlinking some files to make it work. It sucks, it happened on tiger, not just leopard. I’m sorry I can’t be of more help.

    Adam on April 18, 2008 11:06 pm

  7. Hey man, thanks a million for this.

    Max on April 25, 2008 3:40 pm


Leave a Comment