What's New in Edge Rails: RESTful Routes Get a New Custom Delimiter

Posted by ryan
at 9:53 PM on Wednesday, March 28, 2007



No really, I couldn’t think of any better way to title this post, and I apologize for that. However, if you actually clicked on this post from your feed reader, you are definitely a geek, and I like that in you.

So what’s this about? It’s really a tiny little change in RESTful routing, but it negates a lot of material out there, including my own. Whenever you have a custom action route defined in Rails:


map.resources :users, :collection => { :filter => :get }

the resulting route no longer uses a semi-colon (;) to delimit the custom action:


GET /users;filter

and instead will use your standard forward-slash (/):


GET /users/filter

Not a big change at all, but it has big repercussions if you’ve got remote clients accessing these URIs already. (And we all do now-a-days, right?).

tags: ruby, rubyonrails, REST

Comments

Leave a response

  1. BenabikMarch 28, 2007 @ 10:28 PM

    I assume you mead a forward slash (/), not a back-slash (\)

  2. RyanMarch 29, 2007 @ 07:40 AM

    Yes, that’s exactly what I meant, Benabik, thanks. I can never remember the difference between the two.

  3. joost baaijMarch 29, 2007 @ 08:27 AM

    Brilliant! I was unable to serve .ics files with the webcal “protocol” because of the semi colon.

  4. TedMarch 29, 2007 @ 09:03 AM

    Slick. So when do we get the Railscast tutorial on it? ;-)

  5. Jon MaddoxMarch 29, 2007 @ 09:41 AM

    The problems with action caching this caused alone warrants the change. I’m glad they bit the bullet and did it now rather than holding off and doing it later.

  6. Duncan BeeversMarch 30, 2007 @ 12:42 PM

    This has big implications for those using Jeremy Voorhis’ resource_hacks http://www.jvoorhis.com/articles/2006/08/01/announcing-resource_hacks as you’ll need to ensure your resource identities are unique not only amongst themselves, but also amongst your collection actions.

  7. David WaiteMarch 30, 2007 @ 08:09 PM

    Imagine you are a stick figure on the left, looking at it. The difference is that forward slashes lean forward, while back slashes lean back. :)

  8. RyanApril 02, 2007 @ 03:36 PM

    David – nice one. I am indebted to you.

    It’s the little things in life…

  9. SimonApril 06, 2007 @ 12:38 PM

    Any idea if updated delimiter support is planned for 1.2 branch? I’m using 1.2 and this will definitely help with the caching problems I’ve had.