Skip to content

Instantly share code, notes, and snippets.

@joshed-io
Created August 25, 2010 07:31
Show Gist options
  • Save joshed-io/549038 to your computer and use it in GitHub Desktop.
Save joshed-io/549038 to your computer and use it in GitHub Desktop.
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