[Rails] 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
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home