How do I get the HTTP referrer?
Uncategorized
Add comments
Feb 162010
The referrer is the URL the user came from. (It gets passed as part of the headers to the new request). You can get it out of rails this way:
request.env['HTTP_REFERER']
Or the shorter version:
request.referrer
It seems that no one noticed that "referer" is actually not a word – the correct spelling is double-R ("referrer"). request.referer and request.referrer both work, but request.env['HTTP_REFERRER'] does not.