Created
November 1, 2010 23:17
-
-
Save flockonus/659043 to your computer and use it in GitHub Desktop.
/app/controllers/application_controller.rb
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 ApplicationController < ActionController::Base | |
protect_from_forgery | |
after_filter :log_action_taken | |
def current_user | |
@current_user ||= UserSession.find.try :user | |
end | |
# ====== > Should be a plugin along with action_logger.rb | |
def log_action_taken | |
if(current_user || @warn ) | |
stuff = {} | |
stuff['user_id'] = current_user.try :id | |
stuff['action'] = params["action"] | |
stuff['controller'] = params["controller"] | |
stuff['when'] = Time.now | |
stuff['warn'] = @warn.to_i # 0 in case of regular actions | |
stuff['obs'] = @action_obs.to_s | |
if @warn.to_i > 0 | |
stuff['ip'] = request.remote_ip | |
end | |
# Log actions TODO: isso ta certo? | |
p = params.to_hash | |
p.delete('action') | |
p.delete('controller') | |
stuff['params'] = "#(#{p.to_json})" if p.size > 0 | |
ActionLogger.add( "(#{stuff.to_json})" ) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment