Home Play Pinja Bobbity flop

A blog about Ruby, Rails and other Tech. Mostly.

Back to blog

8th Mar 2007, 7:37am
More breakage in rails 1.2 - to_param and routing failures

A couple more things to watch out for in Rails 1.2

The to_param method is no longer a synonym for the id method of an ActiveRecord object. We had an issue because to_param now returns a string. Beware.

Routing came and bit us again. In our previous live setup we constantly got, and accepted, routing failures. In particular the Yahoo Slurp bot tends to stick our email address (from a href="mailto:..." tag) on the end of the url. So we see paths like http://example.com/this/that/theother/foo@example.com coming it. They don't match any of our routes.

Previously this was not a problem. But now rails throws a 500 Application Error, and sends us an email about each one (through Exception Notifier).

So now we need to match any route that anyone happens to throw at us to avoid those exceptions. We used a catch-all route to do it:

map.catchall '*params', :controller=>'application', :action=>'missing_page'

Even if you haven't made a missing_page action, this will still work - a missing action will normally result in a 404, which is probably what you want.

There is more breakage in routes also - we discovered that our action caching is now utterly broken due to some kind of routing issue. But I'll write about that when I've fixed it.


Back to blog