Hi all, How do i get the server url? Much like the PHP function $_SERVER["REQUEST_URI"] Regards, Stijn --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 10/3/07, Tarscher <tarscher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi all, > > How do i get the server url? Much like the PHP function > $_SERVER["REQUEST_URI"]You can get it your controller through request.request_uri or in your view through controller.request.request_uri All the CGI-style variables are available through request.env as well, so this works: request.env[''REQUEST_URI''] But I wonder why you want it? You normally work with the Rails routing system and don''t deal with the details of the request URI. What are you trying to accomplish? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Many thanks for the fast reply. The request.env[''REQUEST_URI''] only returns the path eg: http://localhost:3000/user I get /user . Iactually want http://localhost:3000/ I can do this via request.protocol()+request.request_uri() but I wonder if there is a single method that can do this. I need this for mail sending. I''m creating a user activation system that wan run on multiple domains. When I send out a mail the user has to click alink to activate it. Ofcourse this link is dependant on the domain the site is hosted on. Regards, Stijn On 3 okt, 17:11, "Bob Showalter" <showa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 10/3/07, Tarscher <tarsc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi all, > > > How do i get the server url? Much like the PHP function > > $_SERVER["REQUEST_URI"] > > You can get it your controller through > > request.request_uri > > or in your view through > > controller.request.request_uri > > All the CGI-style variables are available through request.env as well, > so this works: > > request.env[''REQUEST_URI''] > > But I wonder why you want it? You normally work with the Rails routing > system and don''t deal with the details of the request URI. What are > you trying to accomplish?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 10/3/07, Tarscher <tarscher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I need this for mail sending. I''m creating a user activation system > that wan run on multiple domains. When I send out a mail the user has > to click alink to activate it. Ofcourse this link is dependant on the > domain the site is hosted on.Use url_for with :only_path set to false to generate full url''s activate_link = url_for({:only_path => false}, :controller => ''account'', :action => ''activate'', :id => @user) Or, if you have a named route for activation, these generate full url''s by default: activate_link = activate_url(:id => @user) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---