multiple ids on restful action

Hi,

I know this question has come up before, but I couldn't find a satisfying answer. Maybe I didn't look well enough, so any pointers to old messages regarding this subject would be welcome too.

I need some way to pass multiple ids to a resource. Something like /posts/13,14 If I do this I have to manually split the id on ","s in the action, and use post_path([post1, post2].map {|x| x.id}.join(',')) in my views, which I think is not very nice.

If I use post_path([post1, post2]) rails uses to_param on the array which leads to the string "13/14" which is url-encoded to "13%2F14" but the browser just shows a / in the next screen. This is nice, since now the controller can split on "/" and I don't need to do any string-manipulation in my views. Only, if a user wants to enter the url by himself (/posts/13/14) I will get a routing error because now the / isn't url-encoded. I can't expect users to type %2F instead, which just looks ugly. Now I could override Array's to_param method, but I'm sure there is a reason for the default behavior.

So what is the preferred way to solve this? any transparent way to handle this? I mean ActiveRecord handles Post.find(13,14) just fine, Post.find([13,14]) also. Is there a way to make ActionController's routing automatically give params[:id] back as an array if it detects some pattern? (something like from_param maybe?)

Thanks for any help. Mathijs

you could use *ids in your routing which would allow for an array of ids using a non encoded /

Cool,

And how can I do this on RESTful routes? map.resources :posts ....

Will it work too if I use nesting? /posts/13/comments

Greetings, Mathijs