Rails 3 Standard Notification List

One of the coolest things about Rails 3 is notifications. But I would like to ask, is there a list of all the notification names that I can subscribe to?

I could not find it in the documentation (just a few examples), so I can only go to the code if I can not find the answer here.

+6
source share
3 answers

I was looking for the same thing. There seems to be no documentation on this, so I looked at the code and compiled the following list.

Please note that the === operator is used for matching, so you can use a string or regular expression 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 
+4
source

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 details here

+1
source

Source: https://habr.com/ru/post/912216/


All Articles