Skip to content

Instantly share code, notes, and snippets.

@bsodmike
Created April 12, 2012 22:11
Show Gist options
  • Select an option

  • Save bsodmike/2371388 to your computer and use it in GitHub Desktop.

Select an option

Save bsodmike/2371388 to your computer and use it in GitHub Desktop.
Example of subscribing to ActiveSupport::Notifications in Rails 3.2.3
notification: process_action.action_controller 2012-04-13 01:08:35 +0300 2012-04-13 01:08:35 +0300 af358ed7fab884532ec7 {:controller=>"Devise::SessionsController", :action=>"new", :params=>{"action"=>"new", "controller"=>"devise/sessions"}, :format=>:html, :method=>"GET", :path=>"/login/sign_in", :status=>200, :view_runtime=>279.3080806732178, :db_runtime=>40.053}
# add to config/initializers
module ActionController
class PageRequest
def call(name, started, finished, unique_id, payload)
Rails.logger.debug ["notification:", name, started, finished, unique_id, payload].join(" ")
end
end
end
ActiveSupport::Notifications.subscribe('process_action.action_controller', ActionController::PageRequest.new)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment