Use url_for with singleton resources?

Has anyone had any success with url_for and singleton resources?

I have a singleton forum nested under both groups and places:   map.resources :groups do |group|       group.resource :forum   end   map.resources :places do |group|       group.resource :forum   end

So I have paths like /groups/123/forum and /places/456/forum.

In the forum controller, I do what essentially amounts to   @owner = Group.find_by_id(params[:group_id]) || Place.find_by_id(params[:place_id]) so that @owner points to the group or place that has the forum in question.

In the forum views, I want a link that is polymorphic in relation to @owner: it should resolve into group_forum_path(@owner.id) or place_forum_path(@owner.id) depending on the value of @owner.

I've tried url_for([@owner, @owner.forum]), but I get this error: "You have a nil object when you didn't expect it! The error occurred while evaluating nil.to_sym". Debugging it a bit, I find that the method name is correctly resolved into group_forum_path, but this method is then sent _both_ arguments, where it should only be sent the @owner.

Is this a bug? Am I using url_for incorrectly? Anyone have a solution?

For now, I wrote my own url helper to work around it. I might try to fix url_for if I find the time, but first I want to find out if it is in fact broken.

So if I patch like http://pastie.textmate.org/86956, I can do e.g.   polymorphic_url([@parent, @forum], :singleton => true, :routing_type => :path) In practice I'd wrap it.

Is there some way to figure out if the generated route is a singleton, though, so you don't have to specify it manually like this? I found http://dev.rubyonrails.org/ticket/8830 / http://dev.rubyonrails.org/attachment/ticket/8830/polymorphic_routes_for_singleton_resources.diff which makes use of "plural_route", but a grep in edge doesn't turn up anything of the sort. Google only finds the diff in question.