Hi there,
I''m trying to use RESTful routes with an application that has 2
possible URL roots (e.g):
www.example.com/yournamehere/
and
www.yournamehere.com/
(for people who wish to use their own domain name for the app)
with the same application being run for both on a mongrel cluster
behind apache.
Ideally I wouldn''t have 2 seperate deployments, but currently I
can''t
work out how else to create a routes file that works for both such
that I can use url_for throught my app. I have tried adding a
conditional to the routes file:
if
request.env[''SERVER_NAME''].include("example.com")
prefix = ''/:artistname''
else
prefix = ''''
end
and adding the "prefix" variable to the affected routes eg:
map.artist_cv prefix+''/cv/:action'', :controller =>
''cv_items'', :action => ''index''
map.resources :artworks, :path_prefix => prefix
Unsurprisingly nothing has worked so far! I''m not even sure if
it''s
possible to use a variable like that in a route and I can''t access
request.env either as it hasn''t been initialised yet.
Can anyone tell me if I''m totally barking up the wrong tree, and if
they have any better suggestions...
thanks
dorian
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Pablo Castellazzi
2007-Oct-18 06:39 UTC
Re: conditionally loading a particular routes file
Yes you are wrong :P Try add this to your routes.rb when you deploy inside your document root. ActionController::AbstractRequest.relative_url_root = ''/username'' On Oct 17, 4:45 am, tachekent <bartlebo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi there, > I''m trying to use RESTful routes with an application that has 2 > possible URL roots (e.g): > > www.example.com/yournamehere/ > andwww.yournamehere.com/ > (for people who wish to use their own domain name for the app) > > with the same application being run for both on a mongrel cluster > behind apache. > > Ideally I wouldn''t have 2 seperate deployments, but currently I can''t > work out how else to create a routes file that works for both such > that I can use url_for throught my app. I have tried adding a > conditional to the routes file: > > if request.env[''SERVER_NAME''].include("example.com") > prefix = ''/:artistname'' > else > prefix = '''' > end > > and adding the "prefix" variable to the affected routes eg: > > map.artist_cv prefix+''/cv/:action'', :controller => > ''cv_items'', :action => ''index'' > map.resources :artworks, :path_prefix => prefix > > Unsurprisingly nothing has worked so far! I''m not even sure if it''s > possible to use a variable like that in a route and I can''t access > request.env either as it hasn''t been initialised yet. > > Can anyone tell me if I''m totally barking up the wrong tree, and if > they have any better suggestions... > thanks > dorian--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---