Rails 3 resource routes with dots; or, how to make a Ruby developer go a little bit insane

This one cost me at least an hour of frustration.

So apparently the Rails router has considered the dot (“.”) to be a “separator” character along with the slash (“/”) since version 1.2. I don’t know in what context this ever seemed like a good idea, but whatever. It’s not the sort of thing that’s going to bite you every day, but when it does it will be in very weird ways. To wit:

First, a simple routes.rb.

Fill in some typical values, and you get a path:

Now fill in a value with a period in it, and watch it explode:

:action => "create"? What?!! Who said anything about create?!

As it turns out, there is an invocation in your routes file which will fix this:

Now I know what you’re thinking. “That’s so obvious, why didn’t he think of that immediately?” What can I say, some days I’m slow.

UPDATE: Here’s the Rails 2.* version:

And here’s a version that accepts anything BUT slashes for the parameter value: