Hey,
Is is possible to get the full URL
('http://www.sender-domain.com/links/list.html')
from where a user was sent to my site
(www.my-domain.com/controller/action) e.g. by clicking on a link? (I
read about something called a 'request' object, I don't know what it is
or does, is that what I'm looking for?
I'm very new to Rails so I'd appreciate any help!!
Thanks,
Gustav
e-mail: gustav@psychohistorian.org
"Touched by His noodly appendage",
-- www.venganza.org
--
Posted via http://www.ruby-forum.com/.
gustav paul wrote:
> Hey,
>
> Is is possible to get the full URL
> ('http://www.sender-domain.com/links/list.html')
>
> from where a user was sent to my site
> (www.my-domain.com/controller/action) e.g. by clicking on a link? (I
> read about something called a 'request' object, I don't know what it is
> or does, is that what I'm looking for?
It should be available in the controller as
@request.env["HTTP_REFERER"].
--
Alex
Unfortunately, HTTP_REFERER is useless nowadays. There is no stable method of getting that information. Bob Silva http://www.railtie.net/ -----Original Message----- From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Alex Young Sent: Monday, January 30, 2006 9:16 AM To: rails@lists.rubyonrails.org Subject: Re: [Rails] How do I get the the full URL of an incoming request gustav paul wrote: > Hey, > > Is is possible to get the full URL > ('http://www.sender-domain.com/links/list.html') > > from where a user was sent to my site > (www.my-domain.com/controller/action) e.g. by clicking on a link? (I > read about something called a 'request' object, I don't know what it is > or does, is that what I'm looking for? It should be available in the controller as @request.env["HTTP_REFERER"]. -- Alex _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails
Dominique Plante
2006-Jan-30 17:53 UTC
Re: How do I get the the full URL of an incoming request
Confirmed! In a simple controller action, I put: @referringPageURL = @request.env["HTTP_REFERER"] In the corresponding view I entered: referring page = <%= @referringPageURL %> To confirm, I added a standard HTML link to the page in the /public/index.html file, and I also cloned that file as /public/index2.html and also followed the link from there. Note that request.env["HTTP_REFERER"] also seems to work. http://api.rubyonrails.org/classes/ActionController/Base.html hints that to get the IP address where the request came from, you can use request.env["REMOTE_IP"] in the controller. Hope this helps! Thanks, Dominique Alex Young wrote: > gustav paul wrote: >> Hey, >> >> Is is possible to get the full URL >> ('http://www.sender-domain.com/links/list.html') >> >> from where a user was sent to my site >> (www.my-domain.com/controller/action) e.g. by clicking on a link? (I >> read about something called a 'request' object, I don't know what it is >> or does, is that what I'm looking for? > It should be available in the controller as > @request.env["HTTP_REFERER"]. -- Posted via http://www.ruby-forum.com/.
request.remote_ip() works better as it handles proxied IPs also. Again, HTTP_REFERER is not dependable. Some clients send it some don't. Bob Silva http://www.railtie.net/ -----Original Message----- From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Dominique Plante Sent: Monday, January 30, 2006 9:51 AM To: rails@lists.rubyonrails.org Subject: [Rails] Re: How do I get the the full URL of an incoming request Confirmed! In a simple controller action, I put: @referringPageURL = @request.env["HTTP_REFERER"] In the corresponding view I entered: referring page = <%= @referringPageURL %> To confirm, I added a standard HTML link to the page in the /public/index.html file, and I also cloned that file as /public/index2.html and also followed the link from there. Note that request.env["HTTP_REFERER"] also seems to work. http://api.rubyonrails.org/classes/ActionController/Base.html hints that to get the IP address where the request came from, you can use request.env["REMOTE_IP"] in the controller. Hope this helps! Thanks, Dominique Alex Young wrote: > gustav paul wrote: >> Hey, >> >> Is is possible to get the full URL >> ('http://www.sender-domain.com/links/list.html') >> >> from where a user was sent to my site >> (www.my-domain.com/controller/action) e.g. by clicking on a link? (I >> read about something called a 'request' object, I don't know what it is >> or does, is that what I'm looking for? > It should be available in the controller as > @request.env["HTTP_REFERER"]. -- Posted via http://www.ruby-forum.com/. _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails