Hi, How do you get the base url of the HTTP request in the controller? For example, if my app is hosted on http://fudge.wow.com/ and I make a request to http://fudge.wow.com/users/1 How do I get the http://fudge.wow.com/ part of the request in the show action of the users_controller? Thank you! David :) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
*request.env[''HTTP_HOST''] *will give you *=> fudge.wow.com* * request.env[SERVER_PROTOCOL] *will give you server protocol i.e. *=> HTTP *For more details refer to : http://wiki.rubyonrails.org/rails/pages/VariablesInRequestEnv * * * * On Sun, Apr 27, 2008 at 9:59 PM, David Beckwith <dbitsolutions-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > How do you get the base url of the HTTP request in the controller? > > For example, if my app is hosted on http://fudge.wow.com/ > > and I make a request to http://fudge.wow.com/users/1 > > How do I get the http://fudge.wow.com/ part of the request in the show > action of the users_controller? > > Thank you! > > David :) > > > > >-- Arpit Jain Senior Undergraduate Student Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur, India. Ph. : +919733567185 Alt. email: arpit AT intinno.com Web: http://www.arpitjain.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
All that information is in "request" I''m not 100% sure, but I think what you want is request.path or request.url If you do try: raise request.inspect It will tell you everything thats inside request. Hope this helps, Luke David Beckwith wrote:> Hi, > > How do you get the base url of the HTTP request in the controller? > > For example, if my app is hosted on http://fudge.wow.com/ > > and I make a request to http://fudge.wow.com/users/1 > > How do I get the http://fudge.wow.com/ part of the request in the show > action of the users_controller? > > Thank you! > > David :)-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Luke Grimstrup wrote:> All that information is in "request" > > I''m not 100% sure, but I think what you want is request.path or > request.urlAlso try request.relative_url_root. But use with caution, because all the URIs inside your application should be subject to routes.rb. You should expect to change that, and everything will work with the new routes.> If you do try: > raise request.inspect > > It will tell you everything thats inside request.Sometimes .inspect is so obliging, and sometimes not! For a different view, use raise public_methods.sort.inspect -- Phlip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks a lot. I''ll give it a try. D :) On Apr 27, 3:55 pm, "Arpit Jain" <arpitjai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> *request.env[''HTTP_HOST''] > *will give you *=> fudge.wow.com* > * > request.env[SERVER_PROTOCOL] > *will give you server protocol i.e. *=> HTTP > > *For more details refer to :http://wiki.rubyonrails.org/rails/pages/VariablesInRequestEnv > * > * > * > * > On Sun, Apr 27, 2008 at 9:59 PM, David Beckwith <dbitsoluti...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > > > Hi, > > > How do you get the base url of the HTTP request in the controller? > > > For example, if my app is hosted onhttp://fudge.wow.com/ > > > and I make a request tohttp://fudge.wow.com/users/1 > > > How do I get thehttp://fudge.wow.com/part of the request in the show > > action of the users_controller? > > > Thank you! > > > David :) > > -- > Arpit Jain > Senior Undergraduate Student > Department of Computer Science & Engineering > Indian Institute of Technology, Kharagpur, India. > Ph. : +919733567185 > Alt. email: arpit AT intinno.com > Web:http://www.arpitjain.com--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---