Created
November 27, 2009 17:18
-
-
Save etozzato/244131 to your computer and use it in GitHub Desktop.
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
class FailController < ApplicationController | |
def index | |
Fail.add_request(request.host, request.path, request.env['HTTP_REFERER'] || '', request.remote_ip || "0.0.0.0") | |
respond_to do |format| | |
format.html { render :file => "#{RAILS_ROOT}/public/404.html", :status => "404 Not Found" } | |
format.all { render :nothing => true, :status => "404 Not Found" } | |
end | |
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
class Fail < ActiveRecord::Base | |
def self.add_request(host, path, referrer, ip) | |
fail = find_or_initialize_by_host_and_path_and_referer(host, path, referrer) | |
fail.count = 1 + fail.count | |
fail.save | |
UserMailer.deliver_root("Got FAIL!", "Host #{host}, Path #{path}, Referer #{referrer}, IP #{ip}, count #{fail.count}") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment