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?


script/plugin install git://

h2. Example

def index
	@show_adsense = request.referrer_search_engine?

def show
	@track_request = !request.user_agent_bot?

Testing with CURL

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

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