[Rails] Unable to get the domain in my routes.rb to map custom route tables per domain

Abdur-Rahman Advany rails at advany.com
Sat Dec 31 20:14:02 GMT 2005


Hi,

Please look at http://dev.rubyonrails.org/browser/plugins and then 
account_location 
<http://dev.rubyonrails.org/browser/plugins/account_location>, this is 
something your looking for I think...

Ezra Zygmuntowicz wrote:
> Nathaniel-
>
>     I don't think you are going to be able to do this in routes. I 
> could be wrong but I dont think the request obje3ct is available to 
> routes in the way that you want. I think its more likely that you 
> could use a before filter in application.rb to do a redirect to the 
> correct url based on the subdomain. But I could be misunderstanding 
> what you are trying to do. Any more details of what you want to 
> accomplish?
>
> Cheers-
> -Ezra
>
>
> On Dec 30, 2005, at 11:12 PM, Nathaniel S. H. Brown wrote:
>
>> I am still struggling with this. Anyone able to point me in the right
>> direction?
>>
>> -Nb
>>
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>  Nathaniel S. H. Brown                           http://nshb.net
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>>
>>> -----Original Message-----
>>> From: rails-bounces at lists.rubyonrails.org
>>> [mailto:rails-bounces at lists.rubyonrails.org] On Behalf Of
>>> Nathaniel S. H. Brown
>>> Sent: December 30, 2005 5:01 AM
>>> To: rails at lists.rubyonrails.org
>>> Subject: [Rails] Unable to get the domain in my routes.rb to
>>> map custom route tables per domain
>>>
>>> I have tried all night trying to find a way to get the host
>>> name which is currently being used within my routes.rb file
>>> to do some case/when switching for specific domains such as this
>>>
>>>     cgi = ActionController::CgiRequest.new(CGI.new)
>>>     case cgi.domain(1)
>>>         when /www/
>>>             map.connect '', :controller =>
>>> 'public', :action => 'index'
>>>         when /internal/
>>>             map.connect '', :controller => 'admin',
>>> :action => 'index'
>>>     end
>>>
>>> And have had no success. The domain(1) is empty in this case.
>>>
>>> I have tried a similar approach in one of my views, using the
>>> @request.domain(1) and that works PERFECT. Yet I have found
>>> no way to access the same @request.domain(1) within my
>>> routes.rb as the @request object has not been loaded yet.
>>>
>>> One thought was to use the ENV['HTTP_HOST'] variable, but
>>> with my current LIGHTTPD setup, I do not have this
>>> environment variable around.
>>>
>>> Any help would be greatly appreciated.
>>>
>>> Regards,
>>> Nathaniel.
>>>
>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>  Nathaniel S. H. Brown                           http://nshb.net
>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>
>>> _______________________________________________
>>> Rails mailing list
>>> Rails at lists.rubyonrails.org
>>> http://lists.rubyonrails.org/mailman/listinfo/rails
>>>
>>
>> _______________________________________________
>> Rails mailing list
>> Rails at lists.rubyonrails.org
>> http://lists.rubyonrails.org/mailman/listinfo/rails
>>
>
> -Ezra Zygmuntowicz
> WebMaster
> Yakima Herald-Republic Newspaper
> ezra at yakima-herald.com
> 509-577-7732
> _______________________________________________
> Rails mailing list
> Rails at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>



More information about the Rails mailing list