The RequestMetadata plugin adds methods to the Rails request object that allow you to, for example, find out when a request is made by a bot, and when the referrer is a search engine.
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
MIT-LICENSE
README.textile
Rakefile
init.rb
install.rb
uninstall.rb

README.textile

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