Ed W
2007-Mar-13 12:43 UTC
routing conditions only affect recognition, not URL generation??
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 eg: map.with_options( :conditions => { :domain => /(^|\.)blog\./ } ) do |blog| ... end map.with_options( :conditions => { :domain => /(^|\.)track\./ } ) do |track| ... end 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 trivial... Suggestions please... Ed W --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
BraveDave
2007-Mar-15 01:16 UTC
Re: routing conditions only affect recognition, not URL generation??
Ed, 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 this. 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. BraveDave On Mar 13, 6:43 am, Ed W <l...-XJavvHiACVh0ubjbjo6WXg@public.gmane.org> wrote:> 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 > > eg: > > map.with_options( :conditions => { :domain => /(^|\.)blog\./ } ) do > |blog| > ... > end > > map.with_options( :conditions => { :domain => /(^|\.)track\./ } ) do > |track| > ... > end > > 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 > trivial... > > Suggestions please... > > Ed W--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Russell Norris
2007-Mar-15 15:00 UTC
Re: routing conditions only affect recognition, not URL generation??
Have you two read the routing articles on Jamis Bucks'' site? http://weblog.jamisbuck.org/under-the-hood I think you''ll find a good bit of information there that''d help out. Specifically the routing_tricks plugin that Jamis developped. I use it on one of my apps and it''s a godsend. RSL On 3/14/07, BraveDave <DauntlessDavid-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Ed, > 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 > this. > 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. > BraveDave > > > On Mar 13, 6:43 am, Ed W <l...-XJavvHiACVh0ubjbjo6WXg@public.gmane.org> wrote: > > 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 > > > > eg: > > > > map.with_options( :conditions => { :domain => /(^|\.)blog\./ } ) do > > |blog| > > ... > > end > > > > map.with_options( :conditions => { :domain => /(^|\.)track\./ } ) do > > |track| > > ... > > end > > > > 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 > > trivial... > > > > Suggestions please... > > > > Ed W > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---