Advanced routing question

OK, I’m trying to do this the “right way”. (We’re using rails 2.3.11,
btw.)

I have a route which looks like this:

map.unit ‘:district/:community/:resort/:unit’, :controller =>
‘units’, :action => ‘index’, :requirements => {:district =>
districts, :community => communities, :resort => resorts, :unit =>
units }, :method => ‘get’

And in probably hundreds of places in the project we use unit_url,
like this:

unit_url(:district => @district.uri, :community =>
u.unit.resort.community.uri, :resort => u.unit.resort, :unit => u)

(uri is our own special method in the models)

OK, that’s all well and good. Works perfectly. Now, here’s the rub:

We may have a case where the resort name and the community name are
the same, so the url produced may look like:

/carmel/carmel-point/carmel-point/san-antonio-1234

Instead, in this case, we want the url to be:

/carmel/carmel-point/san-antonio-1234

So as to not be redundant. Is there a way to do that while still
using routes and the unit_url magic in the usual way?

Thanks for any pointers/ideas!

Phil