Hi folks, I came across this handy HowTo, but I''m baffled as to how to get it to use the entire domain instead of just the subdomain... http://wiki.rubyonrails.com/rails/show/HowToUseSubdomainsAsAccountKeys Basically, instead of the example''s searching the db table for "37signals", I''d like it to search the table for "37signals.clientsection.com". Thanks, - Chris Johnson
On 7/8/05, Chris Johnson <ceejayoz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi folks, > > I came across this handy HowTo, but I''m baffled as to how to get it to > use the entire domain instead of just the subdomain... > > http://wiki.rubyonrails.com/rails/show/HowToUseSubdomainsAsAccountKeys > > Basically, instead of the example''s searching the db table for > "37signals", I''d like it to search the table for > "37signals.clientsection.com". >This would work, but there must be a better way. before_filter { |c| c.account Account.find_by_subdomain(c.request.subdomains.join("."))}> Thanks, > - Chris Johnson > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Cheers Koz
That seems to do the same thing as the original code - returns just the first subdomain. On 7/7/05, Michael Koziarski <koziarski-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 7/8/05, Chris Johnson <ceejayoz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi folks, > > > > I came across this handy HowTo, but I''m baffled as to how to get it to > > use the entire domain instead of just the subdomain... > > > > http://wiki.rubyonrails.com/rails/show/HowToUseSubdomainsAsAccountKeys > > > > Basically, instead of the example''s searching the db table for > > "37signals", I''d like it to search the table for > > "37signals.clientsection.com". > > > > This would work, but there must be a better way. > > before_filter { |c| c.account > Account.find_by_subdomain(c.request.subdomains.join("."))} > > > Thanks, > > - Chris Johnson > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > Cheers > > > Koz > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Chris Johnson cj-lHH7W0eyjmpWk0Htik3J/w@public.gmane.org
On Jul 7, 2005, at 9:50 PM, Chris Johnson wrote:> That seems to do the same thing as the original code - returns just > the first subdomain. >How about just c.request.host ? Duane Johnson (canadaduane)
> > That seems to do the same thing as the original code - returns just > > the first subdomain.http://dev.rubyonrails.com/file/trunk/actionpack/lib/action_controller/request.rb c.request.domain is what you''re looking for. If you need to test this in your functional tests, use this snippet in your setup: @request = ActionController::TestRequest.new @request.host = "subdomain.example.com" -- rick http://techno-weenie.net