在Rails3中最酷的事情之一就是通知。但我想问一下,是否有我可以订阅的所有通知名称的列表?
我在文档中找不到它(只有几个例子),所以如果我在这里找不到答案,我只能转到代码。
发布于 2012-05-08 20:40:11
这看起来像是一个全面的清单
http://edgeguides.rubyonrails.org/active_support_instrumentation.html#render_partial- action_view
发布于 2012-04-20 23:53:25
我也在找同样的东西。似乎没有关于这方面的文档,所以我浏览了代码并编译了以下列表。
请注意,===运算符用于匹配,因此可以在订阅时使用字符串或正则表达式
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发布于 2012-04-02 17:44:21
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更多信息here
https://stackoverflow.com/questions/9974059
复制相似问题