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.

By Jason

Leave a Reply

Your email address will not be published. Required fields are marked *