Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
49 lines (36 sloc) 959 Bytes

RequestMetadata – Referrer and user agent helper methods

The RequestMetadata Rails plugin allows you to identify when a request is made by a bot and when the referrer is a search engine.

The following methods are added to the request object:

  1. user_agent_matches?
  2. user_agent_bot?
  3. referrer_matches?
  4. referrer_search_engine?

Installation

	
script/plugin install git://github.com/christianhellsten/request_metadata.git
	

h2. Example

	
def index
	@show_adsense = request.referrer_search_engine?
end

def show
	@track_request = !request.user_agent_bot?
end
	

Testing with CURL

	
curl -H 'User-Agent:msnbot' http://localhost:3000
	
	
curl -H 'Referer:http://google.com' http://localhost:3000
	

Copyright © 2008 Christian Hellsten (Aktagon Ltd.), released under the MIT license