Created
August 25, 2010 07:31
-
-
Save joshed-io/549038 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
module Blippin | |
def self.included(base) | |
base.class_eval do | |
before_filter :create_blip | |
after_filter :update_blip | |
end | |
end | |
def create_blip | |
begin | |
session[:last_blip] = Blip.create!( | |
:user_id => current_user.nil? ? nil : current_user.id, | |
:uri => request.env["REQUEST_URI"], | |
:method => request.env["REQUEST_METHOD"], | |
:ip_address => request.env["HTTP_X_FORWARDED_FOR"], | |
:user_agent => request.env["HTTP_USER_AGENT"], | |
:referrer => request.env["HTTP_REFERER"], | |
:login_id => session[:login_id]) | |
rescue RuntimeError | |
Rails.logger.error("Couldn't create blip!") | |
end | |
end | |
def update_blip | |
begin | |
if blip = session[:last_blip] | |
blip.update_attribute(:response_status, response.status) | |
session[:last_blip] = nil | |
end | |
rescue RuntimeError | |
Rails.logger.error("Couldn't update blip!") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment