On Thu, Feb 9, 2012 at 4:58 PM, Kausik Bakshi
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:
> Hi I am a new Rails Developer
>
Welcome :-)
>
> My application_controller is:
>
> class ApplicationController < ActionController::Base
> protect_from_forgery
>
> before_filter :sshow
>
> def sshow
> puts "==========================="
> puts YAML::dump(request.subdomains)
> end
> end
>
> now when I put kausik.localhost:3000 in my browser address bar it
> returns blank Array [] instead [''kausik''] .
>
> Also I rewrite etc/host file for this subdomain.
>
> Please help me
>
What happens with this domain
sub.kausik.localhost:3000 ?
I think in such a domain structure:
E.D.C.B.A
it only takes domains to the left of ''B'' (index less than -2)
(counting from right to left). (That is for .com, .be etc.
might be automatically set to 3 for .co.uk ?).
But it can be modelled with tld_length etc.
It seems, you could do
request.subdomains(-1)
and get everything to the left of ''A''
Check e.g.
https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/http/url.rb
and the tests:
https://github.com/rails/rails/blob/master/actionpack/test/dispatch/request_test.rb#L154
HTH,
Peter
--
*** Available for a new project ***
Peter Vandenabeele
http://twitter.com/peter_v
http://rails.vandenabeele.com
http://coderwall.com/peter_v
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.