drapergeek

I hate DRM…

Posted by draper on Friday, September 4th, 2009

This topic has without a doubt been something that has been talked to death but unfortunately, I have to put in my two cents. Its simple, I hate DRM, its killing me.
Let me be clear, I’m a pirate, by the standards of the MPAA, RIAA & such I am a pirate because I want [...]

continue reading

Ruby for backing up

Posted by draper on Tuesday, May 26th, 2009

Backup, backup, backup! That’s the motto of the day and its good one to live by, for everyone. I personally know that I do not backup as much as I should but that’s mainly because I don’t believe that you can ever backup too much. For my personal computers I use a [...]

continue reading

Setting Rails on OS X Leopard

Posted by draper on Sunday, April 12th, 2009

Over the past year it seems like I’ve setup a new mac for daily usage at least 5 times and for the life of me I can’t remember why this has happened so much. I really haven’t purchased that many new computers(in fact only 1), but I remember this painstaking process quit vividly multiple [...]

continue reading

Setting Rails on OS X Leopard

Posted by draper on Sunday, April 12th, 2009

Over the past year it seems like I’ve setup a new mac for daily usage at least 5 times and for the life of me I can’t remember why this has happened so much. I really haven’t purchased that many new computers(in fact only 1), but I remember this painstaking process quit vividly multiple times. The thing that I dread most about setting up a new computer for use is setting up my rails enviroment. Not that rails in itself is terribly hard to setup(it comes preinstalled on leopard), but for some reason it never fails, I run into trouble setting up MySQL to properly connect to the rails system. I spend pointless hours scouring the internet searching for the ONE solution that finally fixes my issue and then I’m too tired to get any REAL work done by the time I find it. I’m solving this issue now. I am documenting this for myself and everyone else to save some trouble.

First, a few caveats. I am setting up this enviroment for an existing rails application that I’ve been working on for about a year and a half now. It functioning properly is my primary concern. This is the main reason that I must have MySQL working and I can’t rely on sqllite as some other solutions propose. If that works for you, more power to you, but personally I need MySQL and a few other things so lets get to work.

Let me also say this. This may not be the best way to go about this. This is my way of doing it that worked for me. I may have gone all the way around the world and done it completely wrong, but it worked for me and I’m happy with it.

Here are my requirements:

  • Rails
  • MySQL working with rails
  • Passenger – It just makes life easier
  • GIT – to be honest, I don’t use this as of yet, but I’m still trying to convince myself to switch…

Alright everybody got their thinking caps on and ready to go?! Let’s do this!

Preparation

Make sure you Mac is fully up to date. I don’t know if it will change anything but to make things on even grounds, lets start there. As of this writing I’m using OS X 10.5.6 and my ruby version 1.8.6. I realize that 1.8.7 is available however I do not need it at the moment so don’t feel the need to fight forward and get it.

I would personally recommend install the X Code tools available from apple for free. I don’t honestly know if any of those are required but they’re never a bad thing to have around.

I also recommend updating all your ruby gems, this is simple enough:

sudo gem update
sudo gem install rubygems-update
sudo update_rubygems
sudo gem install activeresource
sudo gem update --system

You may need to run the update command a few times to be completely up to date.

Rails

At this point you should already be set on your rails version. If your drop in and run the following command

rails -v

you should see something close to:

Rails 2.2.2

You’re basically set there! Moving on.

MySQL

This where it begins to get dicey. First comes the easy part. Installing MySQL is as simple as grabbing a package from here. Just be sure to pick the appropriate package for your architecture. It may not be newest release, but its close enough for my needs. Also, there is a nice little preference pane in the package that you can install to turn the server on and off.

After throwing this on there unfortunately it still doesn’t take care of the issue of actually connecting rails to MySQL. If you leave it at this point you will be forced to go through the pain of throwing to open your rails app or migrate your database and be given an error similar of missing the MySQL adapter. This is a simple fix just run the command:

    sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

This should take care of MySQL. Also please note, I know that a lot of developers stick with only using SQLlite for development and although while I highly recommend this due to speed, at the moment I still had a few projects that I actually need MySQL on so I done this just for those projects.

Git

It seems that the quickest way to pick up GIT is by using the prebuilt package. If you use Fink or Darwin Ports you could go that way but there is a nice installer prebuilt to a package and they also have a GITGui option which I have not personally checked out. So drop on over here and download the installer and roll with it! I woudl also recommend running the terminal script that adds the command for non terminal programs just in case. I can’t think of a time you would want this but it can’t hurt to have it available.

Phusion Passenger

Don’t get me wrong, mongrel is great, but if you’re working on multiple projects at once, the ability to easily name all your environments using passenger and not have to start them by hand is a BIG plus for development in my book. Also, its not hard at all to setup so to me its well worth the few minutes it takes.
First lets install passenger:

sudo gem install passenger
sudo passenger-install-apache2-module

The second line there is awesome because passenger will go out and do all the hard work for you. The only thing you’ll be told to do is drop a few lines into your apache config and you’re set to go on passenger…well kinda.

At this point you technically are setup and ready to use passenger however, in order to do so you would have to go into your apache config and setup each rails app by hand but thanks to a wonderful preference pane that is offered for free by Fingertips, you don’t have to do any of that. Just grab the preference pane, install it and its pretty much self explanatory.

Conclusions

So that’s it. Not too bad I hope! I’m not sure if this is necessary for most people but if you’re setting up a new computer for rails this would be a good place to start at least. If you feel I should add or change anything, feel free to leave me a comment.

Posted in: featured, programming.

Leave a Reply

    • Most Discussed