Forum: Ruby on Rails routing conditions only affect recognition, not URL generati

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
443a308e12ba2a3082fb6170ca94c2ef?d=identicon&s=25 Ed Wg (ewildgoose)
on 2007-03-13 13:45
(Received via mailing list)
I am hitting a problem where it seems that URL ":conditions=>" correctly
affect URL recognition, but don't affect URL generation.

Basically I have two very similar websites which differ slightly in how
they are laid out, but have substantially similar code.  I want to use a
bit of routing magic to use a single codebase for both sites.  Note: I
use the request_routing plugin to get access to the URL as a condition


    map.with_options( :conditions => { :domain => /(^|\.)blog\./ } ) do

    map.with_options( :conditions => { :domain => /(^|\.)track\./ } ) do

What happens is that at the "track" site the URLs work correctly if I
type them in manually to the browser, ie they get recognised correctly,
but new URLs are all generated in the scheme for the "blog" site
(because it comes higher up in routing order - if I reverse the routes
then the reverse situation occurs)

How can I get my :conditions to take effect during URL generation as
well as recognition.  Examining action_controller/routing.rb isn't

Suggestions please...

Ed W
18989f5699fa8619c8e9b301b6cb5088?d=identicon&s=25 BraveDave (Guest)
on 2007-03-15 02:17
(Received via mailing list)
I've been asking this same question for the last month and keep
getting doors slammed in my face. Mostly, "read the book" type
response (of which I've read most of them) and there's no mention of
I think the secret is keeping all of the HTML 'wording' that the user
see and have it read in from the database on all sites.
I'm easily reachable if you'd like to discuss this sometime.
70225136eacd3d870f64e03bff678655?d=identicon&s=25 Russell Norris (Guest)
on 2007-03-15 16:07
(Received via mailing list)
Have you two read the routing articles on Jamis Bucks' site? I think you'll find a good
bit of
information there that'd help out. Specifically the routing_tricks
that Jamis developped. I use it on one of my apps and it's a godsend.

This topic is locked and can not be replied to.