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:
Or the shorter version:
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.