Skip to content

Instantly share code, notes, and snippets.

@tmeasday
Created October 7, 2011 00:31
Show Gist options
  • Save tmeasday/1269117 to your computer and use it in GitHub Desktop.
Save tmeasday/1269117 to your computer and use it in GitHub Desktop.
How to keep track of the http referer across requests
ApplicationController < ActionController::Base
before_filter :track_referer
protected
def track_referer
@referer = session[:referer] ||= parse_referer(request.headers['HTTP-REFERER'])
end
def parse_referer(url)
...
end
end
<%= main_copy(@referer) %>
def main_copy(referer)
case referer
when :facebook
'Some Facebook specific text'
when :twitter
'bla'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment