2012-04-02 29 views
6

Rails 3中最酷的事情之一是通知。但是我想问一下是否有我可以订阅的所有通知名称的列表?Rails 3标准通知列表

我无法在文档中找到它(只有几个例子),所以我只能去代码,如果我在这里找不到答案。

回答

1

配置/初始化/ 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 

更多信息here

+0

但是,当使用字符串或正则表达式有只是几个例子,我想问的是有可用的通知的完整列表 – 2012-04-02 10:50:55

+0

@说,你能告诉一些关于http://stackoverflow.com/questions/146650 16/rails-activesupport-notifications-wrong-db-runtime-value? – Fivell 2013-02-05 16:59:49

4

我一直在寻找同样的事情。看起来没有关于此的文档,所以我浏览了代码并编译了以下列表。

注意,===运算符用于匹配,这样你就可以订阅

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 
+0

感谢这个 – 2012-04-21 18:54:39