Error when trying to install MySQL on a Mac with Ruby on Rails

When trying to install mysql I got the following error:

Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-mysql-dir=/usr/bin --with-mysql-lib=/usr/lib64/mysql
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

After some googling, I found the following tutorial which I think should help me fix this:

.. only problem with the above blog post is that instead of it being
location mysql_config 
it should be
locate mysql_config

Edit 1: Still didn't work. Installing XCode to see if that fixes it.

Edit 2: After installing XCode it finally installed!!

Edit 3: Looks like it actually didn't work. New error when I used the command: rake db:migrate

rake aborted!
uninitialized constant MysqlCompat::MysqlRes
After googling, I found a StackOverflow post which said to use the command
sudo env ARCHFLAGS="-arch x86_64" gem install mysql
Then I tried the "rake db:migrate" command and it worked!!! I'll update again if something breaks.
Meta