Tuesday, April 04, 2006

Ruby on Rail FC4

So I decided to give Ruby on Rails a spin. By following the instruction from the web site, I got the server (webrick) running pretty fast. However, I was unable to follow the tutorial to create the sample script. After much wrangling, I finally figured out that there are quite a few things left out by the installation howto:

1. make sure you have all the packages through yum:
    yum install mysql-devel irb rdoc ruby-devel ruby-mysql gcc
2. also make sure to install mysql ruby gem
    sudo gem install mysql
3. it would give you the following errors:
ERROR: While executing gem ... (RuntimeError)
ERROR: Failed to build gem native extension.
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
ruby extconf.rb install mysql\nchecking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no

4. goto the directory that it is trying to install from (look for the directory in the error message)
    cd /usr/lib/ruby/gems/1.8/gems/mysql-2.7
sudo ruby extconf.rb --with-mysql-lib=/usr/lib/mysql
sudo gem install mysql
5. Now the rest of the tutorial should work.