Open source

TIP: Apache rewrite rules forgetting stuff


On a side project I'm working on they're using Apache mod_rewrite rules to turn ugly page addresses into pretty ones, e.g.:

RewriteRule widget-(.*)\.htm$ widget.php?id=$1

Nice goal and in general it works well. There was a problem, though, when they started doing this the SAJAX AJAX fancy stuff I wrote stopped working. A few thousand hair and some time later I worked out that one very simple keyword was missing from the rewrite rules, the %{QUERY_STRING} keyword to retain all of the extra fields passed in by SAJAX, e.g.:

RewriteRule widget-(.*)\.htm$ widget.php?id=$1&%{QUERY_STRING}

Also, note the extra ampersand in there before the keyword, you need this to separate the extra values from the one you're passing in from the widget-somat.htm address. Et voila!

Dramatically improve test-driven development


Test-driven development is one of the best benefits that Ruby on Rails brings to modern web development, but it can be a bit tricky, and laborious, constantly tweaking test code, running the tests, then making required changes. Enter autotest, part of a suite called ZenTest, which makes life dramatically easier for you. Instead of having to manually run your tests, autotest runs all of the tests in the background so you immediately see the results of your changes and whether you need to fix something. Good stuff!

Keep track of Ruby on Rails changes


Here's an easy way to keep track of the on-going changes to Ruby on Rails. The Rails team use the system Trac to manage their development and it includes a page to list all of the recent changes. While nice in theory, the fact that by default it shows changes to the development website too makes it a little confusing at first glance, so instead you can use/bookmark this link to see what is going on in the code itself:

Ruby on Rails 1.1 is out


Just a quick mention that Ruby on Rails version 1.1 has just been released, adding some really awesome new features that will continue to make life even easier for web developers everywhere, yes, including even you. Some of the niceties include Javascript templates, to make your AJAX more swishy, JOINs and other fancy things have been added to ActiveRecord, and integration testing to help make your sites more solid - solid as a rock, you might say. Go forth and update, young padawan.

TIP: Instant Rails problems with MySQL


I've mentioned Instant Rails before, the one-step installer for Ruby on Rails for Windows that makes life excedingly easy for beginners? Well, as it turns out there's a problem using it with the included MySQL that makes the combination simply not work - every time you try to do something with MySQL from any of the Rails or Ruby commands you're greated by the loving message

Mysql::Error: Lost connection to MySQL server during query: SELECT version FROM schema_info

Lots of fun there. As it turns out the fix is remarkably easy, simply download the following zip file and follow the instructions in the included readme.txt file, which boil down to copying a single file to somewhere specific. Why this wasn't included in the final Instant Rails release I don't know, but at least the fix is easy.

Huge thanks to Jeroen Nijenhuis for putting this fix together - the Rails newbie world is forever in your debt!


Subscribe to Open source