rails 4.2.0.beta4 → 4.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. checksums.yaml +4 -4
  2. data/guides/Rakefile +3 -1
  3. data/guides/bug_report_templates/action_controller_gem.rb +2 -2
  4. data/guides/bug_report_templates/action_controller_master.rb +2 -2
  5. data/guides/source/3_0_release_notes.md +2 -2
  6. data/guides/source/4_1_release_notes.md +1 -1
  7. data/guides/source/4_2_release_notes.md +250 -225
  8. data/guides/source/_welcome.html.erb +1 -1
  9. data/guides/source/action_controller_overview.md +6 -6
  10. data/guides/source/action_mailer_basics.md +26 -11
  11. data/guides/source/action_view_overview.md +0 -1
  12. data/guides/source/active_job_basics.md +29 -23
  13. data/guides/source/active_record_postgresql.md +2 -7
  14. data/guides/source/active_record_validations.md +1 -0
  15. data/guides/source/active_support_core_extensions.md +1 -1
  16. data/guides/source/active_support_instrumentation.md +5 -5
  17. data/guides/source/asset_pipeline.md +2 -2
  18. data/guides/source/association_basics.md +0 -2
  19. data/guides/source/command_line.md +6 -15
  20. data/guides/source/configuring.md +4 -4
  21. data/guides/source/documents.yaml +0 -1
  22. data/guides/source/engines.md +26 -15
  23. data/guides/source/form_helpers.md +10 -2
  24. data/guides/source/getting_started.md +9 -9
  25. data/guides/source/rails_on_rack.md +2 -2
  26. data/guides/source/ruby_on_rails_guides_guidelines.md +1 -0
  27. data/guides/source/security.md +1 -1
  28. data/guides/source/testing.md +80 -13
  29. data/guides/source/upgrading_ruby_on_rails.md +23 -20
  30. metadata +29 -229
  31. data/guides/output/2_2_release_notes.html +0 -724
  32. data/guides/output/2_3_release_notes.html +0 -870
  33. data/guides/output/3_0_release_notes.html +0 -773
  34. data/guides/output/3_1_release_notes.html +0 -740
  35. data/guides/output/3_2_release_notes.html +0 -797
  36. data/guides/output/4_0_release_notes.html +0 -523
  37. data/guides/output/4_1_release_notes.html +0 -806
  38. data/guides/output/4_2_release_notes.html +0 -728
  39. data/guides/output/Gemfile +0 -6
  40. data/guides/output/_license.html +0 -226
  41. data/guides/output/_welcome.html +0 -233
  42. data/guides/output/action_controller_overview.html +0 -1335
  43. data/guides/output/action_mailer_basics.html +0 -928
  44. data/guides/output/action_view_overview.html +0 -1509
  45. data/guides/output/active_job_basics.html +0 -546
  46. data/guides/output/active_model_basics.html +0 -438
  47. data/guides/output/active_record_basics.html +0 -594
  48. data/guides/output/active_record_callbacks.html +0 -592
  49. data/guides/output/active_record_migrations.html +0 -1123
  50. data/guides/output/active_record_postgresql.html +0 -675
  51. data/guides/output/active_record_querying.html +0 -1796
  52. data/guides/output/active_record_validations.html +0 -1301
  53. data/guides/output/active_support_core_extensions.html +0 -3450
  54. data/guides/output/active_support_instrumentation.html +0 -1121
  55. data/guides/output/api_documentation_guidelines.html +0 -498
  56. data/guides/output/asset_pipeline.html +0 -1167
  57. data/guides/output/association_basics.html +0 -2086
  58. data/guides/output/caching_with_rails.html +0 -553
  59. data/guides/output/command_line.html +0 -791
  60. data/guides/output/configuring.html +0 -1055
  61. data/guides/output/contributing_to_ruby_on_rails.html +0 -657
  62. data/guides/output/credits.html +0 -284
  63. data/guides/output/debugging_rails_applications.html +0 -1014
  64. data/guides/output/development_dependencies_install.html +0 -478
  65. data/guides/output/engines.html +0 -1438
  66. data/guides/output/form_helpers.html +0 -1074
  67. data/guides/output/generators.html +0 -838
  68. data/guides/output/getting_started.html +0 -2092
  69. data/guides/output/i18n.html +0 -1198
  70. data/guides/output/images/akshaysurve.jpg +0 -0
  71. data/guides/output/images/belongs_to.png +0 -0
  72. data/guides/output/images/book_icon.gif +0 -0
  73. data/guides/output/images/bullet.gif +0 -0
  74. data/guides/output/images/chapters_icon.gif +0 -0
  75. data/guides/output/images/check_bullet.gif +0 -0
  76. data/guides/output/images/credits_pic_blank.gif +0 -0
  77. data/guides/output/images/csrf.png +0 -0
  78. data/guides/output/images/edge_badge.png +0 -0
  79. data/guides/output/images/favicon.ico +0 -0
  80. data/guides/output/images/feature_tile.gif +0 -0
  81. data/guides/output/images/footer_tile.gif +0 -0
  82. data/guides/output/images/fxn.png +0 -0
  83. data/guides/output/images/getting_started/article_with_comments.png +0 -0
  84. data/guides/output/images/getting_started/challenge.png +0 -0
  85. data/guides/output/images/getting_started/confirm_dialog.png +0 -0
  86. data/guides/output/images/getting_started/forbidden_attributes_for_new_article.png +0 -0
  87. data/guides/output/images/getting_started/forbidden_attributes_for_new_post.png +0 -0
  88. data/guides/output/images/getting_started/form_with_errors.png +0 -0
  89. data/guides/output/images/getting_started/index_action_with_edit_link.png +0 -0
  90. data/guides/output/images/getting_started/new_article.png +0 -0
  91. data/guides/output/images/getting_started/new_post.png +0 -0
  92. data/guides/output/images/getting_started/post_with_comments.png +0 -0
  93. data/guides/output/images/getting_started/rails_welcome.png +0 -0
  94. data/guides/output/images/getting_started/routing_error_no_controller.png +0 -0
  95. data/guides/output/images/getting_started/routing_error_no_route_matches.png +0 -0
  96. data/guides/output/images/getting_started/show_action_for_articles.png +0 -0
  97. data/guides/output/images/getting_started/show_action_for_posts.png +0 -0
  98. data/guides/output/images/getting_started/template_is_missing_articles_new.png +0 -0
  99. data/guides/output/images/getting_started/template_is_missing_posts_new.png +0 -0
  100. data/guides/output/images/getting_started/undefined_method_post_path.png +0 -0
  101. data/guides/output/images/getting_started/unknown_action_create_for_articles.png +0 -0
  102. data/guides/output/images/getting_started/unknown_action_create_for_posts.png +0 -0
  103. data/guides/output/images/getting_started/unknown_action_new_for_articles.png +0 -0
  104. data/guides/output/images/getting_started/unknown_action_new_for_posts.png +0 -0
  105. data/guides/output/images/grey_bullet.gif +0 -0
  106. data/guides/output/images/habtm.png +0 -0
  107. data/guides/output/images/has_many.png +0 -0
  108. data/guides/output/images/has_many_through.png +0 -0
  109. data/guides/output/images/has_one.png +0 -0
  110. data/guides/output/images/has_one_through.png +0 -0
  111. data/guides/output/images/header_backdrop.png +0 -0
  112. data/guides/output/images/header_tile.gif +0 -0
  113. data/guides/output/images/i18n/demo_html_safe.png +0 -0
  114. data/guides/output/images/i18n/demo_localized_pirate.png +0 -0
  115. data/guides/output/images/i18n/demo_translated_en.png +0 -0
  116. data/guides/output/images/i18n/demo_translated_pirate.png +0 -0
  117. data/guides/output/images/i18n/demo_translation_missing.png +0 -0
  118. data/guides/output/images/i18n/demo_untranslated.png +0 -0
  119. data/guides/output/images/icons/README +0 -5
  120. data/guides/output/images/icons/callouts/1.png +0 -0
  121. data/guides/output/images/icons/callouts/10.png +0 -0
  122. data/guides/output/images/icons/callouts/11.png +0 -0
  123. data/guides/output/images/icons/callouts/12.png +0 -0
  124. data/guides/output/images/icons/callouts/13.png +0 -0
  125. data/guides/output/images/icons/callouts/14.png +0 -0
  126. data/guides/output/images/icons/callouts/15.png +0 -0
  127. data/guides/output/images/icons/callouts/2.png +0 -0
  128. data/guides/output/images/icons/callouts/3.png +0 -0
  129. data/guides/output/images/icons/callouts/4.png +0 -0
  130. data/guides/output/images/icons/callouts/5.png +0 -0
  131. data/guides/output/images/icons/callouts/6.png +0 -0
  132. data/guides/output/images/icons/callouts/7.png +0 -0
  133. data/guides/output/images/icons/callouts/8.png +0 -0
  134. data/guides/output/images/icons/callouts/9.png +0 -0
  135. data/guides/output/images/icons/caution.png +0 -0
  136. data/guides/output/images/icons/example.png +0 -0
  137. data/guides/output/images/icons/home.png +0 -0
  138. data/guides/output/images/icons/important.png +0 -0
  139. data/guides/output/images/icons/next.png +0 -0
  140. data/guides/output/images/icons/note.png +0 -0
  141. data/guides/output/images/icons/prev.png +0 -0
  142. data/guides/output/images/icons/tip.png +0 -0
  143. data/guides/output/images/icons/up.png +0 -0
  144. data/guides/output/images/icons/warning.png +0 -0
  145. data/guides/output/images/nav_arrow.gif +0 -0
  146. data/guides/output/images/oscardelben.jpg +0 -0
  147. data/guides/output/images/polymorphic.png +0 -0
  148. data/guides/output/images/radar.png +0 -0
  149. data/guides/output/images/rails4_features.png +0 -0
  150. data/guides/output/images/rails_guides_kindle_cover.jpg +0 -0
  151. data/guides/output/images/rails_guides_logo.gif +0 -0
  152. data/guides/output/images/rails_logo_remix.gif +0 -0
  153. data/guides/output/images/session_fixation.png +0 -0
  154. data/guides/output/images/tab_grey.gif +0 -0
  155. data/guides/output/images/tab_info.gif +0 -0
  156. data/guides/output/images/tab_note.gif +0 -0
  157. data/guides/output/images/tab_red.gif +0 -0
  158. data/guides/output/images/tab_yellow.gif +0 -0
  159. data/guides/output/images/tab_yellow.png +0 -0
  160. data/guides/output/images/vijaydev.jpg +0 -0
  161. data/guides/output/index.html +0 -354
  162. data/guides/output/initialization.html +0 -876
  163. data/guides/output/javascripts/guides.js +0 -59
  164. data/guides/output/javascripts/jquery.min.js +0 -4
  165. data/guides/output/javascripts/responsive-tables.js +0 -43
  166. data/guides/output/javascripts/syntaxhighlighter/shBrushAS3.js +0 -59
  167. data/guides/output/javascripts/syntaxhighlighter/shBrushAppleScript.js +0 -75
  168. data/guides/output/javascripts/syntaxhighlighter/shBrushBash.js +0 -59
  169. data/guides/output/javascripts/syntaxhighlighter/shBrushCSharp.js +0 -65
  170. data/guides/output/javascripts/syntaxhighlighter/shBrushColdFusion.js +0 -100
  171. data/guides/output/javascripts/syntaxhighlighter/shBrushCpp.js +0 -97
  172. data/guides/output/javascripts/syntaxhighlighter/shBrushCss.js +0 -91
  173. data/guides/output/javascripts/syntaxhighlighter/shBrushDelphi.js +0 -55
  174. data/guides/output/javascripts/syntaxhighlighter/shBrushDiff.js +0 -41
  175. data/guides/output/javascripts/syntaxhighlighter/shBrushErlang.js +0 -52
  176. data/guides/output/javascripts/syntaxhighlighter/shBrushGroovy.js +0 -67
  177. data/guides/output/javascripts/syntaxhighlighter/shBrushJScript.js +0 -52
  178. data/guides/output/javascripts/syntaxhighlighter/shBrushJava.js +0 -57
  179. data/guides/output/javascripts/syntaxhighlighter/shBrushJavaFX.js +0 -58
  180. data/guides/output/javascripts/syntaxhighlighter/shBrushPerl.js +0 -72
  181. data/guides/output/javascripts/syntaxhighlighter/shBrushPhp.js +0 -88
  182. data/guides/output/javascripts/syntaxhighlighter/shBrushPlain.js +0 -33
  183. data/guides/output/javascripts/syntaxhighlighter/shBrushPowerShell.js +0 -74
  184. data/guides/output/javascripts/syntaxhighlighter/shBrushPython.js +0 -64
  185. data/guides/output/javascripts/syntaxhighlighter/shBrushRuby.js +0 -55
  186. data/guides/output/javascripts/syntaxhighlighter/shBrushSass.js +0 -94
  187. data/guides/output/javascripts/syntaxhighlighter/shBrushScala.js +0 -51
  188. data/guides/output/javascripts/syntaxhighlighter/shBrushSql.js +0 -66
  189. data/guides/output/javascripts/syntaxhighlighter/shBrushVb.js +0 -56
  190. data/guides/output/javascripts/syntaxhighlighter/shBrushXml.js +0 -69
  191. data/guides/output/javascripts/syntaxhighlighter/shCore.js +0 -17
  192. data/guides/output/layout.html +0 -448
  193. data/guides/output/layouts_and_rendering.html +0 -1541
  194. data/guides/output/maintenance_policy.html +0 -257
  195. data/guides/output/migrations.html +0 -1360
  196. data/guides/output/nested_model_forms.html +0 -412
  197. data/guides/output/plugins.html +0 -644
  198. data/guides/output/rails_application_templates.html +0 -450
  199. data/guides/output/rails_on_rack.html +0 -547
  200. data/guides/output/routing.html +0 -1631
  201. data/guides/output/ruby_on_rails_guides_guidelines.html +0 -329
  202. data/guides/output/security.html +0 -935
  203. data/guides/output/stylesheets/fixes.css +0 -16
  204. data/guides/output/stylesheets/kindle.css +0 -11
  205. data/guides/output/stylesheets/main.css +0 -713
  206. data/guides/output/stylesheets/print.css +0 -52
  207. data/guides/output/stylesheets/reset.css +0 -43
  208. data/guides/output/stylesheets/responsive-tables.css +0 -50
  209. data/guides/output/stylesheets/style.css +0 -13
  210. data/guides/output/stylesheets/syntaxhighlighter/shCore.css +0 -226
  211. data/guides/output/stylesheets/syntaxhighlighter/shCoreDefault.css +0 -328
  212. data/guides/output/stylesheets/syntaxhighlighter/shCoreDjango.css +0 -331
  213. data/guides/output/stylesheets/syntaxhighlighter/shCoreEclipse.css +0 -339
  214. data/guides/output/stylesheets/syntaxhighlighter/shCoreEmacs.css +0 -324
  215. data/guides/output/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css +0 -328
  216. data/guides/output/stylesheets/syntaxhighlighter/shCoreMDUltra.css +0 -324
  217. data/guides/output/stylesheets/syntaxhighlighter/shCoreMidnight.css +0 -324
  218. data/guides/output/stylesheets/syntaxhighlighter/shCoreRDark.css +0 -324
  219. data/guides/output/stylesheets/syntaxhighlighter/shThemeDefault.css +0 -117
  220. data/guides/output/stylesheets/syntaxhighlighter/shThemeDjango.css +0 -120
  221. data/guides/output/stylesheets/syntaxhighlighter/shThemeEclipse.css +0 -128
  222. data/guides/output/stylesheets/syntaxhighlighter/shThemeEmacs.css +0 -113
  223. data/guides/output/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css +0 -117
  224. data/guides/output/stylesheets/syntaxhighlighter/shThemeMDUltra.css +0 -113
  225. data/guides/output/stylesheets/syntaxhighlighter/shThemeMidnight.css +0 -113
  226. data/guides/output/stylesheets/syntaxhighlighter/shThemeRDark.css +0 -113
  227. data/guides/output/stylesheets/syntaxhighlighter/shThemeRailsGuides.css +0 -116
  228. data/guides/output/testing.html +0 -1350
  229. data/guides/output/upgrading_ruby_on_rails.html +0 -1135
  230. data/guides/output/working_with_javascript_in_rails.html +0 -587
@@ -1,1121 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
- <head>
5
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6
- <meta name="viewport" content="width=device-width, initial-scale=1"/>
7
-
8
- <title>Active Support Instrumentation — Ruby on Rails Guides</title>
9
- <link rel="stylesheet" type="text/css" href="stylesheets/style.css" />
10
- <link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print" />
11
-
12
- <link rel="stylesheet" type="text/css" href="stylesheets/syntaxhighlighter/shCore.css" />
13
- <link rel="stylesheet" type="text/css" href="stylesheets/syntaxhighlighter/shThemeRailsGuides.css" />
14
-
15
- <link rel="stylesheet" type="text/css" href="stylesheets/fixes.css" />
16
-
17
- <link href="images/favicon.ico" rel="shortcut icon" type="image/x-icon" />
18
- </head>
19
- <body class="guide">
20
- <div id="topNav">
21
- <div class="wrapper">
22
- <strong class="more-info-label">More at <a href="http://rubyonrails.org/">rubyonrails.org:</a> </strong>
23
- <span class="red-button more-info-button">
24
- More Ruby on Rails
25
- </span>
26
- <ul class="more-info-links s-hidden">
27
- <li class="more-info"><a href="http://rubyonrails.org/">Overview</a></li>
28
- <li class="more-info"><a href="http://rubyonrails.org/download">Download</a></li>
29
- <li class="more-info"><a href="http://rubyonrails.org/deploy">Deploy</a></li>
30
- <li class="more-info"><a href="https://github.com/rails/rails">Code</a></li>
31
- <li class="more-info"><a href="http://rubyonrails.org/screencasts">Screencasts</a></li>
32
- <li class="more-info"><a href="http://rubyonrails.org/documentation">Documentation</a></li>
33
- <li class="more-info"><a href="http://rubyonrails.org/community">Community</a></li>
34
- <li class="more-info"><a href="http://weblog.rubyonrails.org/">Blog</a></li>
35
- </ul>
36
- </div>
37
- </div>
38
- <div id="header">
39
- <div class="wrapper clearfix">
40
- <h1><a href="index.html" title="Return to home page">Guides.rubyonrails.org</a></h1>
41
- <ul class="nav">
42
- <li><a class="nav-item" href="index.html">Home</a></li>
43
- <li class="guides-index guides-index-large">
44
- <a href="index.html" id="guidesMenu" class="guides-index-item nav-item">Guides Index</a>
45
- <div id="guides" class="clearfix" style="display: none;">
46
- <hr />
47
- <dl class="L">
48
- <dt>Start Here</dt>
49
- <dd><a href="getting_started.html">Getting Started with Rails</a></dd>
50
- <dt>Models</dt>
51
- <dd><a href="active_record_basics.html">Active Record Basics</a></dd>
52
- <dd><a href="active_record_migrations.html">Active Record Migrations</a></dd>
53
- <dd><a href="active_record_validations.html">Active Record Validations</a></dd>
54
- <dd><a href="active_record_callbacks.html">Active Record Callbacks</a></dd>
55
- <dd><a href="association_basics.html">Active Record Associations</a></dd>
56
- <dd><a href="active_record_querying.html">Active Record Query Interface</a></dd>
57
- <dt>Views</dt>
58
- <dd><a href="layouts_and_rendering.html">Layouts and Rendering in Rails</a></dd>
59
- <dd><a href="form_helpers.html">Action View Form Helpers</a></dd>
60
- <dt>Controllers</dt>
61
- <dd><a href="action_controller_overview.html">Action Controller Overview</a></dd>
62
- <dd><a href="routing.html">Rails Routing from the Outside In</a></dd>
63
- </dl>
64
- <dl class="R">
65
- <dt>Digging Deeper</dt>
66
- <dd><a href="active_support_core_extensions.html">Active Support Core Extensions</a></dd>
67
- <dd><a href="i18n.html">Rails Internationalization API</a></dd>
68
- <dd><a href="action_mailer_basics.html">Action Mailer Basics</a></dd>
69
- <dd><a href="active_job_basics.html">Active Job Basics</a></dd>
70
- <dd><a href="security.html">Securing Rails Applications</a></dd>
71
- <dd><a href="debugging_rails_applications.html">Debugging Rails Applications</a></dd>
72
- <dd><a href="configuring.html">Configuring Rails Applications</a></dd>
73
- <dd><a href="command_line.html">Rails Command Line Tools and Rake Tasks</a></dd>
74
- <dd><a href="asset_pipeline.html">Asset Pipeline</a></dd>
75
- <dd><a href="working_with_javascript_in_rails.html">Working with JavaScript in Rails</a></dd>
76
- <dt>Extending Rails</dt>
77
- <dd><a href="rails_on_rack.html">Rails on Rack</a></dd>
78
- <dd><a href="generators.html">Creating and Customizing Rails Generators</a></dd>
79
- <dt>Contributing to Ruby on Rails</dt>
80
- <dd><a href="contributing_to_ruby_on_rails.html">Contributing to Ruby on Rails</a></dd>
81
- <dd><a href="api_documentation_guidelines.html">API Documentation Guidelines</a></dd>
82
- <dd><a href="ruby_on_rails_guides_guidelines.html">Ruby on Rails Guides Guidelines</a></dd>
83
- <dt>Maintenance Policy</dt>
84
- <dd><a href="maintenance_policy.html">Maintenance Policy</a></dd>
85
- <dt>Release Notes</dt>
86
- <dd><a href="upgrading_ruby_on_rails.html">Upgrading Ruby on Rails</a></dd>
87
- <dd><a href="4_1_release_notes.html">Ruby on Rails 4.1 Release Notes</a></dd>
88
- <dd><a href="4_0_release_notes.html">Ruby on Rails 4.0 Release Notes</a></dd>
89
- <dd><a href="3_2_release_notes.html">Ruby on Rails 3.2 Release Notes</a></dd>
90
- <dd><a href="3_1_release_notes.html">Ruby on Rails 3.1 Release Notes</a></dd>
91
- <dd><a href="3_0_release_notes.html">Ruby on Rails 3.0 Release Notes</a></dd>
92
- <dd><a href="2_3_release_notes.html">Ruby on Rails 2.3 Release Notes</a></dd>
93
- <dd><a href="2_2_release_notes.html">Ruby on Rails 2.2 Release Notes</a></dd>
94
- </dl>
95
- </div>
96
- </li>
97
- <li><a class="nav-item" href="contributing_to_ruby_on_rails.html">Contribute</a></li>
98
- <li><a class="nav-item" href="credits.html">Credits</a></li>
99
- <li class="guides-index guides-index-small">
100
- <select class="guides-index-item nav-item">
101
- <option value="index.html">Guides Index</option>
102
- <optgroup label="Start Here">
103
- <option value="getting_started.html">Getting Started with Rails</option>
104
- </optgroup>
105
- <optgroup label="Models">
106
- <option value="active_record_basics.html">Active Record Basics</option>
107
- <option value="active_record_migrations.html">Active Record Migrations</option>
108
- <option value="active_record_validations.html">Active Record Validations</option>
109
- <option value="active_record_callbacks.html">Active Record Callbacks</option>
110
- <option value="association_basics.html">Active Record Associations</option>
111
- <option value="active_record_querying.html">Active Record Query Interface</option>
112
- </optgroup>
113
- <optgroup label="Views">
114
- <option value="layouts_and_rendering.html">Layouts and Rendering in Rails</option>
115
- <option value="form_helpers.html">Action View Form Helpers</option>
116
- </optgroup>
117
- <optgroup label="Controllers">
118
- <option value="action_controller_overview.html">Action Controller Overview</option>
119
- <option value="routing.html">Rails Routing from the Outside In</option>
120
- </optgroup>
121
- <optgroup label="Digging Deeper">
122
- <option value="active_support_core_extensions.html">Active Support Core Extensions</option>
123
- <option value="i18n.html">Rails Internationalization API</option>
124
- <option value="action_mailer_basics.html">Action Mailer Basics</option>
125
- <option value="active_job_basics.html">Active Job Basics</option>
126
- <option value="security.html">Securing Rails Applications</option>
127
- <option value="debugging_rails_applications.html">Debugging Rails Applications</option>
128
- <option value="configuring.html">Configuring Rails Applications</option>
129
- <option value="command_line.html">Rails Command Line Tools and Rake Tasks</option>
130
- <option value="asset_pipeline.html">Asset Pipeline</option>
131
- <option value="working_with_javascript_in_rails.html">Working with JavaScript in Rails</option>
132
- </optgroup>
133
- <optgroup label="Extending Rails">
134
- <option value="rails_on_rack.html">Rails on Rack</option>
135
- <option value="generators.html">Creating and Customizing Rails Generators</option>
136
- </optgroup>
137
- <optgroup label="Contributing to Ruby on Rails">
138
- <option value="contributing_to_ruby_on_rails.html">Contributing to Ruby on Rails</option>
139
- <option value="api_documentation_guidelines.html">API Documentation Guidelines</option>
140
- <option value="ruby_on_rails_guides_guidelines.html">Ruby on Rails Guides Guidelines</option>
141
- </optgroup>
142
- <optgroup label="Maintenance Policy">
143
- <option value="maintenance_policy.html">Maintenance Policy</option>
144
- </optgroup>
145
- <optgroup label="Release Notes">
146
- <option value="upgrading_ruby_on_rails.html">Upgrading Ruby on Rails</option>
147
- <option value="4_1_release_notes.html">Ruby on Rails 4.1 Release Notes</option>
148
- <option value="4_0_release_notes.html">Ruby on Rails 4.0 Release Notes</option>
149
- <option value="3_2_release_notes.html">Ruby on Rails 3.2 Release Notes</option>
150
- <option value="3_1_release_notes.html">Ruby on Rails 3.1 Release Notes</option>
151
- <option value="3_0_release_notes.html">Ruby on Rails 3.0 Release Notes</option>
152
- <option value="2_3_release_notes.html">Ruby on Rails 2.3 Release Notes</option>
153
- <option value="2_2_release_notes.html">Ruby on Rails 2.2 Release Notes</option>
154
- </optgroup>
155
- </select>
156
- </li>
157
- </ul>
158
- </div>
159
- </div>
160
- <hr class="hide" />
161
-
162
- <div id="feature">
163
- <div class="wrapper">
164
- <h2>Active Support Instrumentation</h2><p>Active Support is a part of core Rails that provides Ruby language extensions, utilities and other things. One of the things it includes is an instrumentation API that can be used inside an application to measure certain actions that occur within Ruby code, such as that inside a Rails application or the framework itself. It is not limited to Rails, however. It can be used independently in other Ruby scripts if it is so desired.</p><p>In this guide, you will learn how to use the instrumentation API inside of Active Support to measure events inside of Rails and other Ruby code.</p><p>After reading this guide, you will know:</p>
165
- <ul>
166
- <li>What instrumentation can provide.</li>
167
- <li>The hooks inside the Rails framework for instrumentation.</li>
168
- <li>Adding a subscriber to a hook.</li>
169
- <li>Building a custom instrumentation implementation.</li>
170
- </ul>
171
-
172
-
173
- <div id="subCol">
174
- <h3 class="chapter"><img src="images/chapters_icon.gif" alt="" />Chapters</h3>
175
- <ol class="chapters">
176
- <li><a href="#introduction-to-instrumentation">Introduction to instrumentation</a></li>
177
- <li><a href="#rails-framework-hooks">Rails framework hooks</a></li>
178
- <li>
179
- <a href="#action-controller">Action Controller</a>
180
-
181
- <ul>
182
- <li><a href="#write_fragment.action_controller">write_fragment.action_controller</a></li>
183
- <li><a href="#read_fragment.action_controller">read_fragment.action_controller</a></li>
184
- <li><a href="#expire_fragment.action_controller">expire_fragment.action_controller</a></li>
185
- <li><a href="#exist_fragment-questionmark.action_controller">exist_fragment?.action_controller</a></li>
186
- <li><a href="#write_page.action_controller">write_page.action_controller</a></li>
187
- <li><a href="#expire_page.action_controller">expire_page.action_controller</a></li>
188
- <li><a href="#start_processing.action_controller">start_processing.action_controller</a></li>
189
- <li><a href="#process_action.action_controller">process_action.action_controller</a></li>
190
- <li><a href="#send_file.action_controller">send_file.action_controller</a></li>
191
- <li><a href="#send_data.action_controller">send_data.action_controller</a></li>
192
- <li><a href="#redirect_to.action_controller">redirect_to.action_controller</a></li>
193
- <li><a href="#halted_callback.action_controller">halted_callback.action_controller</a></li>
194
- </ul>
195
- </li>
196
- <li>
197
- <a href="#action-view">Action View</a>
198
-
199
- <ul>
200
- <li><a href="#render_template.action_view">render_template.action_view</a></li>
201
- <li><a href="#render_partial.action_view">render_partial.action_view</a></li>
202
- </ul>
203
- </li>
204
- <li>
205
- <a href="#active-record">Active Record</a>
206
-
207
- <ul>
208
- <li><a href="#sql.active_record">sql.active_record</a></li>
209
- <li><a href="#identity.active_record">identity.active_record</a></li>
210
- </ul>
211
- </li>
212
- <li>
213
- <a href="#action-mailer">Action Mailer</a>
214
-
215
- <ul>
216
- <li><a href="#receive.action_mailer">receive.action_mailer</a></li>
217
- <li><a href="#deliver.action_mailer">deliver.action_mailer</a></li>
218
- </ul>
219
- </li>
220
- <li>
221
- <a href="#activeresource">ActiveResource</a>
222
-
223
- <ul>
224
- <li><a href="#request.active_resource">request.active_resource</a></li>
225
- </ul>
226
- </li>
227
- <li>
228
- <a href="#active-support">Active Support</a>
229
-
230
- <ul>
231
- <li><a href="#cache_read.active_support">cache_read.active_support</a></li>
232
- <li><a href="#cache_generate.active_support">cache_generate.active_support</a></li>
233
- <li><a href="#cache_fetch_hit.active_support">cache_fetch_hit.active_support</a></li>
234
- <li><a href="#cache_write.active_support">cache_write.active_support</a></li>
235
- <li><a href="#cache_delete.active_support">cache_delete.active_support</a></li>
236
- <li><a href="#cache_exist-questionmark.active_support">cache_exist?.active_support</a></li>
237
- </ul>
238
- </li>
239
- <li>
240
- <a href="#railties">Railties</a>
241
-
242
- <ul>
243
- <li><a href="#load_config_initializer.railties">load_config_initializer.railties</a></li>
244
- </ul>
245
- </li>
246
- <li>
247
- <a href="#rails">Rails</a>
248
-
249
- <ul>
250
- <li><a href="#deprecation.rails">deprecation.rails</a></li>
251
- </ul>
252
- </li>
253
- <li><a href="#subscribing-to-an-event">Subscribing to an event</a></li>
254
- <li><a href="#creating-custom-events">Creating custom events</a></li>
255
- </ol>
256
-
257
- </div>
258
-
259
- </div>
260
- </div>
261
-
262
- <div id="container">
263
- <div class="wrapper">
264
- <div id="mainCol">
265
- <h3 id="introduction-to-instrumentation">1 Introduction to instrumentation</h3><p>The instrumentation API provided by Active Support allows developers to provide hooks which other developers may hook into. There are several of these within the Rails framework, as described below in (TODO: link to section detailing each hook point). With this API, developers can choose to be notified when certain events occur inside their application or another piece of Ruby code.</p><p>For example, there is a hook provided within Active Record that is called every time Active Record uses an SQL query on a database. This hook could be <strong>subscribed</strong> to, and used to track the number of queries during a certain action. There's another hook around the processing of an action of a controller. This could be used, for instance, to track how long a specific action has taken.</p><p>You are even able to create your own events inside your application which you can later subscribe to.</p><h3 id="rails-framework-hooks">2 Rails framework hooks</h3><p>Within the Ruby on Rails framework, there are a number of hooks provided for common events. These are detailed below.</p><h3 id="action-controller">3 Action Controller</h3><h4 id="write_fragment.action_controller">3.1 write_fragment.action_controller</h4>
266
- <table>
267
- <thead>
268
- <tr>
269
- <th>Key</th>
270
- <th>Value</th>
271
- </tr>
272
- </thead>
273
- <tbody>
274
- <tr>
275
- <td><code>:key</code></td>
276
- <td>The complete key</td>
277
- </tr>
278
- </tbody>
279
- </table>
280
- <div class="code_container">
281
- <pre class="brush: ruby; gutter: false; toolbar: false">
282
- {
283
- key: 'posts/1-dashboard-view'
284
- }
285
-
286
- </pre>
287
- </div>
288
- <h4 id="read_fragment.action_controller">3.2 read_fragment.action_controller</h4>
289
- <table>
290
- <thead>
291
- <tr>
292
- <th>Key</th>
293
- <th>Value</th>
294
- </tr>
295
- </thead>
296
- <tbody>
297
- <tr>
298
- <td><code>:key</code></td>
299
- <td>The complete key</td>
300
- </tr>
301
- </tbody>
302
- </table>
303
- <div class="code_container">
304
- <pre class="brush: ruby; gutter: false; toolbar: false">
305
- {
306
- key: 'posts/1-dashboard-view'
307
- }
308
-
309
- </pre>
310
- </div>
311
- <h4 id="expire_fragment.action_controller">3.3 expire_fragment.action_controller</h4>
312
- <table>
313
- <thead>
314
- <tr>
315
- <th>Key</th>
316
- <th>Value</th>
317
- </tr>
318
- </thead>
319
- <tbody>
320
- <tr>
321
- <td><code>:key</code></td>
322
- <td>The complete key</td>
323
- </tr>
324
- </tbody>
325
- </table>
326
- <div class="code_container">
327
- <pre class="brush: ruby; gutter: false; toolbar: false">
328
- {
329
- key: 'posts/1-dashboard-view'
330
- }
331
-
332
- </pre>
333
- </div>
334
- <h4 id="exist_fragment-questionmark.action_controller">3.4 exist_fragment?.action_controller</h4>
335
- <table>
336
- <thead>
337
- <tr>
338
- <th>Key</th>
339
- <th>Value</th>
340
- </tr>
341
- </thead>
342
- <tbody>
343
- <tr>
344
- <td><code>:key</code></td>
345
- <td>The complete key</td>
346
- </tr>
347
- </tbody>
348
- </table>
349
- <div class="code_container">
350
- <pre class="brush: ruby; gutter: false; toolbar: false">
351
- {
352
- key: 'posts/1-dashboard-view'
353
- }
354
-
355
- </pre>
356
- </div>
357
- <h4 id="write_page.action_controller">3.5 write_page.action_controller</h4>
358
- <table>
359
- <thead>
360
- <tr>
361
- <th>Key</th>
362
- <th>Value</th>
363
- </tr>
364
- </thead>
365
- <tbody>
366
- <tr>
367
- <td><code>:path</code></td>
368
- <td>The complete path</td>
369
- </tr>
370
- </tbody>
371
- </table>
372
- <div class="code_container">
373
- <pre class="brush: ruby; gutter: false; toolbar: false">
374
- {
375
- path: '/users/1'
376
- }
377
-
378
- </pre>
379
- </div>
380
- <h4 id="expire_page.action_controller">3.6 expire_page.action_controller</h4>
381
- <table>
382
- <thead>
383
- <tr>
384
- <th>Key</th>
385
- <th>Value</th>
386
- </tr>
387
- </thead>
388
- <tbody>
389
- <tr>
390
- <td><code>:path</code></td>
391
- <td>The complete path</td>
392
- </tr>
393
- </tbody>
394
- </table>
395
- <div class="code_container">
396
- <pre class="brush: ruby; gutter: false; toolbar: false">
397
- {
398
- path: '/users/1'
399
- }
400
-
401
- </pre>
402
- </div>
403
- <h4 id="start_processing.action_controller">3.7 start_processing.action_controller</h4>
404
- <table>
405
- <thead>
406
- <tr>
407
- <th>Key</th>
408
- <th>Value</th>
409
- </tr>
410
- </thead>
411
- <tbody>
412
- <tr>
413
- <td><code>:controller</code></td>
414
- <td>The controller name</td>
415
- </tr>
416
- <tr>
417
- <td><code>:action</code></td>
418
- <td>The action</td>
419
- </tr>
420
- <tr>
421
- <td><code>:params</code></td>
422
- <td>Hash of request parameters without any filtered parameter</td>
423
- </tr>
424
- <tr>
425
- <td><code>:format</code></td>
426
- <td>html/js/json/xml etc</td>
427
- </tr>
428
- <tr>
429
- <td><code>:method</code></td>
430
- <td>HTTP request verb</td>
431
- </tr>
432
- <tr>
433
- <td><code>:path</code></td>
434
- <td>Request path</td>
435
- </tr>
436
- </tbody>
437
- </table>
438
- <div class="code_container">
439
- <pre class="brush: ruby; gutter: false; toolbar: false">
440
- {
441
- controller: "PostsController",
442
- action: "new",
443
- params: { "action" =&gt; "new", "controller" =&gt; "posts" },
444
- format: :html,
445
- method: "GET",
446
- path: "/posts/new"
447
- }
448
-
449
- </pre>
450
- </div>
451
- <h4 id="process_action.action_controller">3.8 process_action.action_controller</h4>
452
- <table>
453
- <thead>
454
- <tr>
455
- <th>Key</th>
456
- <th>Value</th>
457
- </tr>
458
- </thead>
459
- <tbody>
460
- <tr>
461
- <td><code>:controller</code></td>
462
- <td>The controller name</td>
463
- </tr>
464
- <tr>
465
- <td><code>:action</code></td>
466
- <td>The action</td>
467
- </tr>
468
- <tr>
469
- <td><code>:params</code></td>
470
- <td>Hash of request parameters without any filtered parameter</td>
471
- </tr>
472
- <tr>
473
- <td><code>:format</code></td>
474
- <td>html/js/json/xml etc</td>
475
- </tr>
476
- <tr>
477
- <td><code>:method</code></td>
478
- <td>HTTP request verb</td>
479
- </tr>
480
- <tr>
481
- <td><code>:path</code></td>
482
- <td>Request path</td>
483
- </tr>
484
- <tr>
485
- <td><code>:view_runtime</code></td>
486
- <td>Amount spent in view in ms</td>
487
- </tr>
488
- </tbody>
489
- </table>
490
- <div class="code_container">
491
- <pre class="brush: ruby; gutter: false; toolbar: false">
492
- {
493
- controller: "PostsController",
494
- action: "index",
495
- params: {"action" =&gt; "index", "controller" =&gt; "posts"},
496
- format: :html,
497
- method: "GET",
498
- path: "/posts",
499
- status: 200,
500
- view_runtime: 46.848,
501
- db_runtime: 0.157
502
- }
503
-
504
- </pre>
505
- </div>
506
- <h4 id="send_file.action_controller">3.9 send_file.action_controller</h4>
507
- <table>
508
- <thead>
509
- <tr>
510
- <th>Key</th>
511
- <th>Value</th>
512
- </tr>
513
- </thead>
514
- <tbody>
515
- <tr>
516
- <td><code>:path</code></td>
517
- <td>Complete path to the file</td>
518
- </tr>
519
- </tbody>
520
- </table>
521
- <div class="info"><p>Additional keys may be added by the caller.</p></div><h4 id="send_data.action_controller">3.10 send_data.action_controller</h4><p><code>ActionController</code> does not had any specific information to the payload. All options are passed through to the payload.</p><h4 id="redirect_to.action_controller">3.11 redirect_to.action_controller</h4>
522
- <table>
523
- <thead>
524
- <tr>
525
- <th>Key</th>
526
- <th>Value</th>
527
- </tr>
528
- </thead>
529
- <tbody>
530
- <tr>
531
- <td><code>:status</code></td>
532
- <td>HTTP response code</td>
533
- </tr>
534
- <tr>
535
- <td><code>:location</code></td>
536
- <td>URL to redirect to</td>
537
- </tr>
538
- </tbody>
539
- </table>
540
- <div class="code_container">
541
- <pre class="brush: ruby; gutter: false; toolbar: false">
542
- {
543
- status: 302,
544
- location: "http://localhost:3000/posts/new"
545
- }
546
-
547
- </pre>
548
- </div>
549
- <h4 id="halted_callback.action_controller">3.12 halted_callback.action_controller</h4>
550
- <table>
551
- <thead>
552
- <tr>
553
- <th>Key</th>
554
- <th>Value</th>
555
- </tr>
556
- </thead>
557
- <tbody>
558
- <tr>
559
- <td><code>:filter</code></td>
560
- <td>Filter that halted the action</td>
561
- </tr>
562
- </tbody>
563
- </table>
564
- <div class="code_container">
565
- <pre class="brush: ruby; gutter: false; toolbar: false">
566
- {
567
- filter: ":halting_filter"
568
- }
569
-
570
- </pre>
571
- </div>
572
- <h3 id="action-view">4 Action View</h3><h4 id="render_template.action_view">4.1 render_template.action_view</h4>
573
- <table>
574
- <thead>
575
- <tr>
576
- <th>Key</th>
577
- <th>Value</th>
578
- </tr>
579
- </thead>
580
- <tbody>
581
- <tr>
582
- <td><code>:identifier</code></td>
583
- <td>Full path to template</td>
584
- </tr>
585
- <tr>
586
- <td><code>:layout</code></td>
587
- <td>Applicable layout</td>
588
- </tr>
589
- </tbody>
590
- </table>
591
- <div class="code_container">
592
- <pre class="brush: ruby; gutter: false; toolbar: false">
593
- {
594
- identifier: "/Users/adam/projects/notifications/app/views/posts/index.html.erb",
595
- layout: "layouts/application"
596
- }
597
-
598
- </pre>
599
- </div>
600
- <h4 id="render_partial.action_view">4.2 render_partial.action_view</h4>
601
- <table>
602
- <thead>
603
- <tr>
604
- <th>Key</th>
605
- <th>Value</th>
606
- </tr>
607
- </thead>
608
- <tbody>
609
- <tr>
610
- <td><code>:identifier</code></td>
611
- <td>Full path to template</td>
612
- </tr>
613
- </tbody>
614
- </table>
615
- <div class="code_container">
616
- <pre class="brush: ruby; gutter: false; toolbar: false">
617
- {
618
- identifier: "/Users/adam/projects/notifications/app/views/posts/_form.html.erb",
619
- }
620
-
621
- </pre>
622
- </div>
623
- <h3 id="active-record">5 Active Record</h3><h4 id="sql.active_record">5.1 sql.active_record</h4>
624
- <table>
625
- <thead>
626
- <tr>
627
- <th>Key</th>
628
- <th>Value</th>
629
- </tr>
630
- </thead>
631
- <tbody>
632
- <tr>
633
- <td><code>:sql</code></td>
634
- <td>SQL statement</td>
635
- </tr>
636
- <tr>
637
- <td><code>:name</code></td>
638
- <td>Name of the operation</td>
639
- </tr>
640
- <tr>
641
- <td><code>:object_id</code></td>
642
- <td><code>self.object_id</code></td>
643
- </tr>
644
- </tbody>
645
- </table>
646
- <div class="info"><p>The adapters will add their own data as well.</p></div><div class="code_container">
647
- <pre class="brush: ruby; gutter: false; toolbar: false">
648
- {
649
- sql: "SELECT \"posts\".* FROM \"posts\" ",
650
- name: "Post Load",
651
- connection_id: 70307250813140,
652
- binds: []
653
- }
654
-
655
- </pre>
656
- </div>
657
- <h4 id="identity.active_record">5.2 identity.active_record</h4>
658
- <table>
659
- <thead>
660
- <tr>
661
- <th>Key</th>
662
- <th>Value</th>
663
- </tr>
664
- </thead>
665
- <tbody>
666
- <tr>
667
- <td><code>:line</code></td>
668
- <td>Primary Key of object in the identity map</td>
669
- </tr>
670
- <tr>
671
- <td><code>:name</code></td>
672
- <td>Record's class</td>
673
- </tr>
674
- <tr>
675
- <td><code>:connection_id</code></td>
676
- <td><code>self.object_id</code></td>
677
- </tr>
678
- </tbody>
679
- </table>
680
- <h3 id="action-mailer">6 Action Mailer</h3><h4 id="receive.action_mailer">6.1 receive.action_mailer</h4>
681
- <table>
682
- <thead>
683
- <tr>
684
- <th>Key</th>
685
- <th>Value</th>
686
- </tr>
687
- </thead>
688
- <tbody>
689
- <tr>
690
- <td><code>:mailer</code></td>
691
- <td>Name of the mailer class</td>
692
- </tr>
693
- <tr>
694
- <td><code>:message_id</code></td>
695
- <td>ID of the message, generated by the Mail gem</td>
696
- </tr>
697
- <tr>
698
- <td><code>:subject</code></td>
699
- <td>Subject of the mail</td>
700
- </tr>
701
- <tr>
702
- <td><code>:to</code></td>
703
- <td>To address(es) of the mail</td>
704
- </tr>
705
- <tr>
706
- <td><code>:from</code></td>
707
- <td>From address of the mail</td>
708
- </tr>
709
- <tr>
710
- <td><code>:bcc</code></td>
711
- <td>BCC addresses of the mail</td>
712
- </tr>
713
- <tr>
714
- <td><code>:cc</code></td>
715
- <td>CC addresses of the mail</td>
716
- </tr>
717
- <tr>
718
- <td><code>:date</code></td>
719
- <td>Date of the mail</td>
720
- </tr>
721
- <tr>
722
- <td><code>:mail</code></td>
723
- <td>The encoded form of the mail</td>
724
- </tr>
725
- </tbody>
726
- </table>
727
- <div class="code_container">
728
- <pre class="brush: ruby; gutter: false; toolbar: false">
729
- {
730
- mailer: "Notification",
731
- message_id: "4f5b5491f1774_181b23fc3d4434d38138e5@mba.local.mail",
732
- subject: "Rails Guides",
733
- to: ["users@rails.com", "ddh@rails.com"],
734
- from: ["me@rails.com"],
735
- date: Sat, 10 Mar 2012 14:18:09 +0100,
736
- mail: "..." # omitted for brevity
737
- }
738
-
739
- </pre>
740
- </div>
741
- <h4 id="deliver.action_mailer">6.2 deliver.action_mailer</h4>
742
- <table>
743
- <thead>
744
- <tr>
745
- <th>Key</th>
746
- <th>Value</th>
747
- </tr>
748
- </thead>
749
- <tbody>
750
- <tr>
751
- <td><code>:mailer</code></td>
752
- <td>Name of the mailer class</td>
753
- </tr>
754
- <tr>
755
- <td><code>:message_id</code></td>
756
- <td>ID of the message, generated by the Mail gem</td>
757
- </tr>
758
- <tr>
759
- <td><code>:subject</code></td>
760
- <td>Subject of the mail</td>
761
- </tr>
762
- <tr>
763
- <td><code>:to</code></td>
764
- <td>To address(es) of the mail</td>
765
- </tr>
766
- <tr>
767
- <td><code>:from</code></td>
768
- <td>From address of the mail</td>
769
- </tr>
770
- <tr>
771
- <td><code>:bcc</code></td>
772
- <td>BCC addresses of the mail</td>
773
- </tr>
774
- <tr>
775
- <td><code>:cc</code></td>
776
- <td>CC addresses of the mail</td>
777
- </tr>
778
- <tr>
779
- <td><code>:date</code></td>
780
- <td>Date of the mail</td>
781
- </tr>
782
- <tr>
783
- <td><code>:mail</code></td>
784
- <td>The encoded form of the mail</td>
785
- </tr>
786
- </tbody>
787
- </table>
788
- <div class="code_container">
789
- <pre class="brush: ruby; gutter: false; toolbar: false">
790
- {
791
- mailer: "Notification",
792
- message_id: "4f5b5491f1774_181b23fc3d4434d38138e5@mba.local.mail",
793
- subject: "Rails Guides",
794
- to: ["users@rails.com", "ddh@rails.com"],
795
- from: ["me@rails.com"],
796
- date: Sat, 10 Mar 2012 14:18:09 +0100,
797
- mail: "..." # omitted for brevity
798
- }
799
-
800
- </pre>
801
- </div>
802
- <h3 id="activeresource">7 ActiveResource</h3><h4 id="request.active_resource">7.1 request.active_resource</h4>
803
- <table>
804
- <thead>
805
- <tr>
806
- <th>Key</th>
807
- <th>Value</th>
808
- </tr>
809
- </thead>
810
- <tbody>
811
- <tr>
812
- <td><code>:method</code></td>
813
- <td>HTTP method</td>
814
- </tr>
815
- <tr>
816
- <td><code>:request_uri</code></td>
817
- <td>Complete URI</td>
818
- </tr>
819
- <tr>
820
- <td><code>:result</code></td>
821
- <td>HTTP response object</td>
822
- </tr>
823
- </tbody>
824
- </table>
825
- <h3 id="active-support">8 Active Support</h3><h4 id="cache_read.active_support">8.1 cache_read.active_support</h4>
826
- <table>
827
- <thead>
828
- <tr>
829
- <th>Key</th>
830
- <th>Value</th>
831
- </tr>
832
- </thead>
833
- <tbody>
834
- <tr>
835
- <td><code>:key</code></td>
836
- <td>Key used in the store</td>
837
- </tr>
838
- <tr>
839
- <td><code>:hit</code></td>
840
- <td>If this read is a hit</td>
841
- </tr>
842
- <tr>
843
- <td><code>:super_operation</code></td>
844
- <td>:fetch is added when a read is used with <code>#fetch</code>
845
- </td>
846
- </tr>
847
- </tbody>
848
- </table>
849
- <h4 id="cache_generate.active_support">8.2 cache_generate.active_support</h4><p>This event is only used when <code>#fetch</code> is called with a block.</p>
850
- <table>
851
- <thead>
852
- <tr>
853
- <th>Key</th>
854
- <th>Value</th>
855
- </tr>
856
- </thead>
857
- <tbody>
858
- <tr>
859
- <td><code>:key</code></td>
860
- <td>Key used in the store</td>
861
- </tr>
862
- </tbody>
863
- </table>
864
- <div class="info"><p>Options passed to fetch will be merged with the payload when writing to the store</p></div><div class="code_container">
865
- <pre class="brush: ruby; gutter: false; toolbar: false">
866
- {
867
- key: 'name-of-complicated-computation'
868
- }
869
-
870
- </pre>
871
- </div>
872
- <h4 id="cache_fetch_hit.active_support">8.3 cache_fetch_hit.active_support</h4><p>This event is only used when <code>#fetch</code> is called with a block.</p>
873
- <table>
874
- <thead>
875
- <tr>
876
- <th>Key</th>
877
- <th>Value</th>
878
- </tr>
879
- </thead>
880
- <tbody>
881
- <tr>
882
- <td><code>:key</code></td>
883
- <td>Key used in the store</td>
884
- </tr>
885
- </tbody>
886
- </table>
887
- <div class="info"><p>Options passed to fetch will be merged with the payload.</p></div><div class="code_container">
888
- <pre class="brush: ruby; gutter: false; toolbar: false">
889
- {
890
- key: 'name-of-complicated-computation'
891
- }
892
-
893
- </pre>
894
- </div>
895
- <h4 id="cache_write.active_support">8.4 cache_write.active_support</h4>
896
- <table>
897
- <thead>
898
- <tr>
899
- <th>Key</th>
900
- <th>Value</th>
901
- </tr>
902
- </thead>
903
- <tbody>
904
- <tr>
905
- <td><code>:key</code></td>
906
- <td>Key used in the store</td>
907
- </tr>
908
- </tbody>
909
- </table>
910
- <div class="info"><p>Cache stores may add their own keys</p></div><div class="code_container">
911
- <pre class="brush: ruby; gutter: false; toolbar: false">
912
- {
913
- key: 'name-of-complicated-computation'
914
- }
915
-
916
- </pre>
917
- </div>
918
- <h4 id="cache_delete.active_support">8.5 cache_delete.active_support</h4>
919
- <table>
920
- <thead>
921
- <tr>
922
- <th>Key</th>
923
- <th>Value</th>
924
- </tr>
925
- </thead>
926
- <tbody>
927
- <tr>
928
- <td><code>:key</code></td>
929
- <td>Key used in the store</td>
930
- </tr>
931
- </tbody>
932
- </table>
933
- <div class="code_container">
934
- <pre class="brush: ruby; gutter: false; toolbar: false">
935
- {
936
- key: 'name-of-complicated-computation'
937
- }
938
-
939
- </pre>
940
- </div>
941
- <h4 id="cache_exist-questionmark.active_support">8.6 cache_exist?.active_support</h4>
942
- <table>
943
- <thead>
944
- <tr>
945
- <th>Key</th>
946
- <th>Value</th>
947
- </tr>
948
- </thead>
949
- <tbody>
950
- <tr>
951
- <td><code>:key</code></td>
952
- <td>Key used in the store</td>
953
- </tr>
954
- </tbody>
955
- </table>
956
- <div class="code_container">
957
- <pre class="brush: ruby; gutter: false; toolbar: false">
958
- {
959
- key: 'name-of-complicated-computation'
960
- }
961
-
962
- </pre>
963
- </div>
964
- <h3 id="railties">9 Railties</h3><h4 id="load_config_initializer.railties">9.1 load_config_initializer.railties</h4>
965
- <table>
966
- <thead>
967
- <tr>
968
- <th>Key</th>
969
- <th>Value</th>
970
- </tr>
971
- </thead>
972
- <tbody>
973
- <tr>
974
- <td><code>:initializer</code></td>
975
- <td>Path to loaded initializer from <code>config/initializers</code>
976
- </td>
977
- </tr>
978
- </tbody>
979
- </table>
980
- <h3 id="rails">10 Rails</h3><h4 id="deprecation.rails">10.1 deprecation.rails</h4>
981
- <table>
982
- <thead>
983
- <tr>
984
- <th>Key</th>
985
- <th>Value</th>
986
- </tr>
987
- </thead>
988
- <tbody>
989
- <tr>
990
- <td><code>:message</code></td>
991
- <td>The deprecation warning</td>
992
- </tr>
993
- <tr>
994
- <td><code>:callstack</code></td>
995
- <td>Where the deprecation came from</td>
996
- </tr>
997
- </tbody>
998
- </table>
999
- <h3 id="subscribing-to-an-event">11 Subscribing to an event</h3><p>Subscribing to an event is easy. Use <code>ActiveSupport::Notifications.subscribe</code> with a block to
1000
- listen to any notification.</p><p>The block receives the following arguments:</p>
1001
- <ul>
1002
- <li>The name of the event</li>
1003
- <li>Time when it started</li>
1004
- <li>Time when it finished</li>
1005
- <li>An unique ID for this event</li>
1006
- <li>The payload (described in previous sections)</li>
1007
- </ul>
1008
- <div class="code_container">
1009
- <pre class="brush: ruby; gutter: false; toolbar: false">
1010
- ActiveSupport::Notifications.subscribe "process_action.action_controller" do |name, started, finished, unique_id, data|
1011
- # your own custom stuff
1012
- Rails.logger.info "#{name} Received!"
1013
- end
1014
-
1015
- </pre>
1016
- </div>
1017
- <p>Defining all those block arguments each time can be tedious. You can easily create an <code>ActiveSupport::Notifications::Event</code>
1018
- from block arguments like this:</p><div class="code_container">
1019
- <pre class="brush: ruby; gutter: false; toolbar: false">
1020
- ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*args|
1021
- event = ActiveSupport::Notifications::Event.new *args
1022
-
1023
- event.name # =&gt; "process_action.action_controller"
1024
- event.duration # =&gt; 10 (in milliseconds)
1025
- event.payload # =&gt; {:extra=&gt;information}
1026
-
1027
- Rails.logger.info "#{event} Received!"
1028
- end
1029
-
1030
- </pre>
1031
- </div>
1032
- <p>Most times you only care about the data itself. Here is a shortcut to just get the data.</p><div class="code_container">
1033
- <pre class="brush: ruby; gutter: false; toolbar: false">
1034
- ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*args|
1035
- data = args.extract_options!
1036
- data # { extra: :information }
1037
- end
1038
-
1039
- </pre>
1040
- </div>
1041
- <p>You may also subscribe to events matching a regular expression. This enables you to subscribe to
1042
- multiple events at once. Here's you could subscribe to everything from <code>ActionController</code>.</p><div class="code_container">
1043
- <pre class="brush: ruby; gutter: false; toolbar: false">
1044
- ActiveSupport::Notifications.subscribe /action_controller/ do |*args|
1045
- # inspect all ActionController events
1046
- end
1047
-
1048
- </pre>
1049
- </div>
1050
- <h3 id="creating-custom-events">12 Creating custom events</h3><p>Adding your own events is easy as well. <code>ActiveSupport::Notifications</code> will take care of
1051
- all the heavy lifting for you. Simply call <code>instrument</code> with a <code>name</code>, <code>payload</code> and a block.
1052
- The notification will be sent after the block returns. <code>ActiveSupport</code> will generate the start and end times
1053
- as well as the unique ID. All data passed into the <code>instrument</code> call will make it into the payload.</p><p>Here's an example:</p><div class="code_container">
1054
- <pre class="brush: ruby; gutter: false; toolbar: false">
1055
- ActiveSupport::Notifications.instrument "my.custom.event", this: :data do
1056
- # do your custom stuff here
1057
- end
1058
-
1059
- </pre>
1060
- </div>
1061
- <p>Now you can listen to this event with:</p><div class="code_container">
1062
- <pre class="brush: ruby; gutter: false; toolbar: false">
1063
- ActiveSupport::Notifications.subscribe "my.custom.event" do |name, started, finished, unique_id, data|
1064
- puts data.inspect # {:this=&gt;:data}
1065
- end
1066
-
1067
- </pre>
1068
- </div>
1069
- <p>You should follow Rails conventions when defining your own events. The format is: <code>event.library</code>.
1070
- If you application is sending Tweets, you should create an event named <code>tweet.twitter</code>.</p>
1071
-
1072
- <h3>Feedback</h3>
1073
- <p>
1074
- You're encouraged to help improve the quality of this guide.
1075
- </p>
1076
- <p>
1077
- Please contribute if you see any typos or factual errors.
1078
- To get started, you can read our <a href="http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#contributing-to-the-rails-documentation">documentation contributions</a> section.
1079
- </p>
1080
- <p>
1081
- You may also find incomplete content, or stuff that is not up to date.
1082
- Please do add any missing documentation for master. Make sure to check
1083
- <a href="http://edgeguides.rubyonrails.org">Edge Guides</a> first to verify
1084
- if the issues are already fixed or not on the master branch.
1085
- Check the <a href="ruby_on_rails_guides_guidelines.html">Ruby on Rails Guides Guidelines</a>
1086
- for style and conventions.
1087
- </p>
1088
- <p>
1089
- If for whatever reason you spot something to fix but cannot patch it yourself, please
1090
- <a href="https://github.com/rails/rails/issues">open an issue</a>.
1091
- </p>
1092
- <p>And last but not least, any kind of discussion regarding Ruby on Rails
1093
- documentation is very welcome in the <a href="http://groups.google.com/group/rubyonrails-docs">rubyonrails-docs mailing list</a>.
1094
- </p>
1095
- </div>
1096
- </div>
1097
- </div>
1098
-
1099
- <hr class="hide" />
1100
- <div id="footer">
1101
- <div class="wrapper">
1102
- <p>This work is licensed under a <a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International</a> License</p>
1103
- <p>"Rails", "Ruby on Rails", and the Rails logo are trademarks of David Heinemeier Hansson. All rights reserved.</p>
1104
-
1105
- </div>
1106
- </div>
1107
-
1108
- <script type="text/javascript" src="javascripts/jquery.min.js"></script>
1109
- <script type="text/javascript" src="javascripts/responsive-tables.js"></script>
1110
- <script type="text/javascript" src="javascripts/guides.js"></script>
1111
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shCore.js"></script>
1112
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushRuby.js"></script>
1113
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushXml.js"></script>
1114
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushSql.js"></script>
1115
- <script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushPlain.js"></script>
1116
- <script type="text/javascript">
1117
- SyntaxHighlighter.all();
1118
- $(guidesIndex.bind);
1119
- </script>
1120
- </body>
1121
- </html>