2012-04-02 28 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