Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 standard notifications list

One of the coolest thing in Rails 3 is notifications. But I would like to ask if there is a list of all notifications names that I can subscribe to?

I couldn't find it in documentation (only few examples), so I can only go to the code if I don't find the answer here.

like image 635
Konrad Szczęśniak Avatar asked Apr 02 '12 09:04

Konrad Szczęśniak


3 Answers

This seems like a comprehensive list

http://edgeguides.rubyonrails.org/active_support_instrumentation.html#render_partial- action_view

like image 164
Ian.mc Avatar answered Nov 03 '22 06:11

Ian.mc


I was looking for the exact same thing. It seems there's no documentation on this, so I browsed the code and compiled the following list.

Note that the === operator is used for matching, so you can use a string or a regex when subscribing

receive.action_mailer
deliver.action_mailer

write_fragment.action_controller
read_fragment.action_controller
exist_fragment?.action_controller
expire_fragment.action_controller

expire_page.action_controller
write_page.action_controller

start_processing.action_controller
process_action.action_controller
send_file.action_controller
send_data.action_controller
redirect_to.action_controller
halted_callback.action_controller

render_collection.action_view
render_partial.action_view
render_template.action_view
!render_template.action_view

sql.active_record

cache_read.active_support
cache_fetch_hit.active_support
cache_generate.active_support
cache_write.active_support
cache_delete.active_support
cache_exist?.active_support

deprecation.rails

render
like image 37
alf Avatar answered Nov 03 '22 07:11

alf


config/initializers/notifications.rb

ActiveSupport::Notifications.subscribe "process_action.action_controller" do |name, start, finish, id, payload|
      PageRequest.create! do |page_request|
        page_request.path = payload[:path]
        page_request.page_duration = (finish - start) * 1000
        page_request.view_duration = payload[:view_runtime]
        page_request.db_duration = payload[:db_runtime]
      end
    end

more info here

like image 31
Said Kaldybaev Avatar answered Nov 03 '22 07:11

Said Kaldybaev