Rails: Semicolons Out, Slashes In
« One Laptop Per Chicago
» Human-Readable ActiveResource URLs
Code: map, mapping, Rails, resources, routes, routing, semicolon, slash, slashes, URLs
As of r6485, Edge Rails resource routes use / as the URL separator for actions instead of ;. This will be in Rails 2.0 (and I like / more), so I wanted to get prepared for the change by updating my URLs now. I didn’t want to move to Edge Rails (too exciting for me), so I grabbed the change, dropped it into a source file, and loaded it into my app (thank you, open classes).
If you want to get ready now, grab
slash_urls.rb and drop it in your lib directory. At the top of your config/routes.rb, add the line:
And now all my URLs on NearbyGamers use slashes instead of semicolons. I only had one or two actions on my ActiveResource routes besides the built-in CRUD, so I’m not worried about doing a 301 redirects.