REST route with multiple ids

How can I configure a REST route to accept multiple ids?

for instance, in Highrise by 37signals tags have either routes like
tags/47824
or
tags/47824,43622,43628

I suppose it’s done with some regexp expertize, but I have none, and I
wouldn’t know where to put it. A hand would be appreciated.

In the instance of those comma-separated multiple tags, params[:id] is
“47824,43622,43628” and it’s just being split or handled in the
method. I don’t think :id gets coerced to an integer because that
could spoil implementations of routing which use to_param differently.
[I could totally be off on that.] But I’m pretty sure that
“47824,43622,43628” is just a string getting split on the commas
something like

Tag.find params[:id].split(",")

I’d love to find out if I’m wrong and what the real implementation is.
I’m kinda curious now.

RSL

On Oct 4, 8:31 am, “Russell N.” [email protected] wrote:

I’d love to find out if I’m wrong and what the real implementation is.
I’m kinda curious now.

Russell, you are right. I just tried this using a Page model. You
could also send up a list of the tag names instead of the id’s, making
it a little more semantic (see Jonathan L. on
http://www.vaporbase.com/postings/A_Micro-CMS_in_Rails).

but how do I set a route for that? Right now I get this error:

no route found to match “/tags/19,16” with {:method=>:get}

I’m on rails 1.2.4. Are you on 2.0, or am I missing something else?

OK, that works, thanks Pablo.

So if I by adding this line I’m actually removing ‘,’ from the
SEPARATORS array… You’ve introduced me to SEPARATORS, and made me
understand I could use any characters except the ones in that array.
So instead of adding that line and using ‘,’ II decided to simply use
‘+’, à la del.icio.us. There’s no drawbacks in using ‘+’ is there? For
example:

tags/645+456+456

On Oct 7, 10:02 pm, Pablo C. [email protected]

Add this to your environment.rb
ActionController::Routing::SEPARATORS = %w(/ ; . ?)

It works, but “+” is a space URL encoded (RFC1738). That’s mean in
your controller you should split by spaces instead of ‘+’.