joestelmach.com

Ruby On Rails

All this talk about Ruby on Rails - A List Apart is now using it, a multitude of users on The Server Side and other message boards are using it, and they are all saying the same thing - it's the hottest new thing in web development. What's next? Will I read on Slashdot tommorow morning that Amazon.com and ebay have switched over to a Ruby on Rails system? Not likely, but my interest has been stirred enough to install the framework and work through the basic tutorial involving the creation of a thrilling recipe book application. After completing the tutorial, which took about 20 minutes once I got past some installation headaches, I have to say that I am highly impressed. I am so taken aback by the results that I'm thinking of moving this PHP-based site over to Ruby on Rails immediately (cold weather is coming soon anyway, I'll need a winter project.)

The framework is not without flaw though. Documentation is sparse, and as I mentioned before, the installation on my powerbook was a bit of a struggle (Admittedly, I didn't look all that hard for help outside of the documentation, but should I really have to?) The trouble started while working through the recipe tutorial. All was going fine until about page 3, when it came time to start up the web server and test the application, which resulted in the following strange error:

ActiveRecord::StatementInvalid in Recipe#new
No database selected: SHOW FIELDS FROM recipes script/server:49

After a bit of frustration, I realized that I had never installed the framework's mysql component. I attempted this with the following command, as per the documentation:

gem install mysql

Which resulted in the following nasty output:

pbook:/Users/joe/Rails root# gem install mysql -- -with-mysql-dir=/usr/local/mysql
Attempting local installation of 'mysql'
Local gem file not found: mysql*.gem
Attempting remote installation of 'mysql'
Building native extensions. This could take a while...
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.6 for inspection.
ruby extconf.rb install mysql -- -with-mysql-dir=/usr/local/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... no
checking for mysql_query() in -lmysqlclient... no

I decided to try and install from source, noting from the manual that this must be done with gcc 3.3 as follows:

sudo gcc_select 3.3
ruby extconf.rb install mysql -- --with-mysql-config=/usr/local/mysql-standard-4.1.12-apple- darwin7.9.0-powerpc/bin/mysql_config

All was happy after this. I still can't get over the amount of work I didn't have to do to get this thing to do something interesting. No sql strings leading to concatenation-hell, no connection management, no form processing, and barely any code at all. Pretty cool.

Comments
blog comments powered by Disqus