Created
October 7, 2011 00:31
-
-
Save tmeasday/1269117 to your computer and use it in GitHub Desktop.
How to keep track of the http referer across requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= main_copy(@referer) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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