actionpack 2.3.18 → 3.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

Files changed (513) hide show
  1. data/CHANGELOG +15 -64
  2. data/README +39 -48
  3. data/lib/abstract_controller.rb +22 -0
  4. data/lib/abstract_controller/base.rb +191 -0
  5. data/lib/abstract_controller/callbacks.rb +113 -0
  6. data/lib/abstract_controller/collector.rb +30 -0
  7. data/lib/abstract_controller/compatibility.rb +18 -0
  8. data/lib/abstract_controller/helpers.rb +163 -0
  9. data/lib/abstract_controller/layouts.rb +413 -0
  10. data/lib/abstract_controller/localized_cache.rb +49 -0
  11. data/lib/abstract_controller/logger.rb +13 -0
  12. data/lib/abstract_controller/rendering.rb +238 -0
  13. data/lib/{action_controller → abstract_controller}/translation.rb +1 -1
  14. data/lib/action_controller.rb +68 -102
  15. data/lib/action_controller/base.rb +77 -1409
  16. data/lib/action_controller/caching.rb +58 -45
  17. data/lib/action_controller/caching/actions.rb +100 -114
  18. data/lib/action_controller/caching/fragments.rb +17 -19
  19. data/lib/action_controller/caching/pages.rb +12 -6
  20. data/lib/action_controller/caching/sweeping.rb +42 -0
  21. data/lib/action_controller/deprecated.rb +5 -0
  22. data/lib/action_controller/deprecated/dispatcher.rb +28 -0
  23. data/lib/action_controller/deprecated/integration_test.rb +2 -0
  24. data/lib/action_controller/deprecated/performance_test.rb +1 -0
  25. data/lib/action_controller/metal.rb +125 -0
  26. data/lib/action_controller/metal/compatibility.rb +141 -0
  27. data/lib/action_controller/metal/conditional_get.rb +86 -0
  28. data/lib/action_controller/metal/configuration.rb +28 -0
  29. data/lib/action_controller/metal/cookies.rb +17 -0
  30. data/lib/action_controller/metal/exceptions.rb +46 -0
  31. data/lib/action_controller/metal/flash.rb +28 -0
  32. data/lib/action_controller/metal/head.rb +33 -0
  33. data/lib/action_controller/metal/helpers.rb +116 -0
  34. data/lib/action_controller/metal/hide_actions.rb +50 -0
  35. data/lib/action_controller/{http_authentication.rb → metal/http_authentication.rb} +18 -15
  36. data/lib/action_controller/metal/instrumentation.rb +99 -0
  37. data/lib/action_controller/metal/mime_responds.rb +300 -0
  38. data/lib/action_controller/metal/rack_delegation.rb +35 -0
  39. data/lib/action_controller/metal/redirecting.rb +90 -0
  40. data/lib/action_controller/metal/renderers.rb +95 -0
  41. data/lib/action_controller/metal/rendering.rb +69 -0
  42. data/lib/action_controller/metal/request_forgery_protection.rb +115 -0
  43. data/lib/action_controller/metal/rescue.rb +13 -0
  44. data/lib/action_controller/metal/responder.rb +220 -0
  45. data/lib/action_controller/{session_management.rb → metal/session_management.rb} +5 -14
  46. data/lib/action_controller/{streaming.rb → metal/streaming.rb} +13 -12
  47. data/lib/action_controller/metal/testing.rb +42 -0
  48. data/lib/action_controller/metal/url_for.rb +157 -0
  49. data/lib/action_controller/{verification.rb → metal/verification.rb} +41 -41
  50. data/lib/action_controller/middleware.rb +38 -0
  51. data/lib/action_controller/polymorphic_routes.rb +20 -26
  52. data/lib/action_controller/railtie.rb +30 -0
  53. data/lib/action_controller/railties/subscriber.rb +63 -0
  54. data/lib/action_controller/record_identifier.rb +3 -16
  55. data/lib/action_controller/test_case.rb +156 -18
  56. data/lib/action_controller/url_rewriter.rb +47 -200
  57. data/lib/action_controller/vendor/html-scanner.rb +16 -12
  58. data/lib/action_controller/vendor/html-scanner/html/node.rb +1 -1
  59. data/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +12 -9
  60. data/lib/action_dispatch.rb +88 -0
  61. data/lib/action_dispatch/http/cache.rb +123 -0
  62. data/lib/action_dispatch/http/filter_parameters.rb +98 -0
  63. data/lib/{action_controller → action_dispatch/http}/headers.rb +8 -8
  64. data/lib/action_dispatch/http/mime_negotiation.rb +101 -0
  65. data/lib/{action_controller → action_dispatch/http}/mime_type.rb +30 -11
  66. data/lib/{action_controller → action_dispatch/http}/mime_types.rb +5 -3
  67. data/lib/action_dispatch/http/parameters.rb +49 -0
  68. data/lib/action_dispatch/http/request.rb +223 -0
  69. data/lib/action_dispatch/http/response.rb +209 -0
  70. data/lib/action_dispatch/http/upload.rb +48 -0
  71. data/lib/action_dispatch/http/url.rb +129 -0
  72. data/lib/action_dispatch/middleware/callbacks.rb +50 -0
  73. data/lib/action_dispatch/middleware/cascade.rb +29 -0
  74. data/lib/action_dispatch/middleware/cookies.rb +216 -0
  75. data/lib/{action_controller → action_dispatch/middleware}/flash.rb +51 -90
  76. data/lib/action_dispatch/middleware/head.rb +18 -0
  77. data/lib/action_dispatch/middleware/params_parser.rb +78 -0
  78. data/lib/action_dispatch/middleware/rescue.rb +26 -0
  79. data/lib/action_dispatch/middleware/session/abstract_store.rb +209 -0
  80. data/lib/{action_controller → action_dispatch/middleware}/session/cookie_store.rb +56 -60
  81. data/lib/action_dispatch/middleware/session/mem_cache_store.rb +47 -0
  82. data/lib/action_dispatch/middleware/show_exceptions.rb +173 -0
  83. data/lib/{action_controller/middleware_stack.rb → action_dispatch/middleware/stack.rb} +23 -13
  84. data/lib/action_dispatch/middleware/static.rb +44 -0
  85. data/lib/{action_controller → action_dispatch/middleware}/templates/rescues/_request_and_response.erb +10 -3
  86. data/lib/{action_controller → action_dispatch/middleware}/templates/rescues/_trace.erb +4 -4
  87. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb +10 -0
  88. data/lib/{action_controller → action_dispatch/middleware}/templates/rescues/layout.erb +2 -2
  89. data/lib/{action_controller → action_dispatch/middleware}/templates/rescues/missing_template.erb +0 -0
  90. data/lib/{action_controller → action_dispatch/middleware}/templates/rescues/routing_error.erb +0 -0
  91. data/lib/{action_controller → action_dispatch/middleware}/templates/rescues/template_error.erb +3 -3
  92. data/lib/{action_controller → action_dispatch/middleware}/templates/rescues/unknown_action.erb +0 -0
  93. data/lib/action_dispatch/railtie.rb +15 -0
  94. data/lib/action_dispatch/routing.rb +217 -0
  95. data/lib/action_dispatch/routing/deprecated_mapper.rb +877 -0
  96. data/lib/action_dispatch/routing/mapper.rb +649 -0
  97. data/lib/action_dispatch/routing/route.rb +55 -0
  98. data/lib/action_dispatch/routing/route_set.rb +445 -0
  99. data/lib/action_dispatch/testing/assertions.rb +21 -0
  100. data/lib/action_dispatch/testing/assertions/dom.rb +37 -0
  101. data/lib/{action_controller/assertions/model_assertions.rb → action_dispatch/testing/assertions/model.rb} +2 -4
  102. data/lib/action_dispatch/testing/assertions/response.rb +154 -0
  103. data/lib/{action_controller/assertions/routing_assertions.rb → action_dispatch/testing/assertions/routing.rb} +72 -34
  104. data/lib/{action_controller/assertions/selector_assertions.rb → action_dispatch/testing/assertions/selector.rb} +14 -11
  105. data/lib/{action_controller/assertions/tag_assertions.rb → action_dispatch/testing/assertions/tag.rb} +25 -14
  106. data/lib/{action_controller → action_dispatch/testing}/integration.rb +173 -406
  107. data/lib/action_dispatch/testing/performance_test.rb +17 -0
  108. data/lib/action_dispatch/testing/test_process.rb +42 -0
  109. data/lib/action_dispatch/testing/test_request.rb +83 -0
  110. data/lib/action_dispatch/testing/test_response.rb +136 -0
  111. data/lib/action_pack/version.rb +3 -3
  112. data/lib/action_view.rb +29 -26
  113. data/lib/action_view/base.rb +101 -148
  114. data/lib/action_view/context.rb +44 -0
  115. data/lib/action_view/helpers.rb +6 -4
  116. data/lib/action_view/helpers/{active_record_helper.rb → active_model_helper.rb} +63 -63
  117. data/lib/action_view/helpers/asset_tag_helper.rb +166 -31
  118. data/lib/action_view/helpers/cache_helper.rb +1 -1
  119. data/lib/action_view/helpers/capture_helper.rb +40 -8
  120. data/lib/action_view/helpers/csrf_helper.rb +2 -4
  121. data/lib/action_view/helpers/date_helper.rb +14 -15
  122. data/lib/action_view/helpers/form_helper.rb +121 -24
  123. data/lib/action_view/helpers/form_options_helper.rb +26 -25
  124. data/lib/action_view/helpers/form_tag_helper.rb +42 -33
  125. data/lib/action_view/helpers/javascript_helper.rb +1 -109
  126. data/lib/action_view/helpers/number_helper.rb +4 -1
  127. data/lib/action_view/helpers/prototype_helper.rb +75 -499
  128. data/lib/action_view/helpers/raw_output_helper.rb +1 -1
  129. data/lib/action_view/helpers/record_tag_helper.rb +3 -3
  130. data/lib/action_view/helpers/sanitize_helper.rb +3 -2
  131. data/lib/action_view/helpers/scriptaculous_helper.rb +89 -53
  132. data/lib/action_view/helpers/tag_helper.rb +12 -13
  133. data/lib/action_view/helpers/text_helper.rb +33 -38
  134. data/lib/action_view/helpers/translation_helper.rb +11 -35
  135. data/lib/action_view/helpers/url_helper.rb +140 -134
  136. data/lib/action_view/locale/en.yml +34 -28
  137. data/lib/action_view/paths.rb +27 -24
  138. data/lib/action_view/railtie.rb +17 -0
  139. data/lib/action_view/railties/subscriber.rb +24 -0
  140. data/lib/action_view/{partials.rb → render/partials.rb} +161 -51
  141. data/lib/action_view/render/rendering.rb +117 -0
  142. data/lib/action_view/template.rb +88 -217
  143. data/lib/action_view/template/error.rb +105 -0
  144. data/lib/action_view/template/handler.rb +41 -0
  145. data/lib/action_view/template/handlers.rb +54 -0
  146. data/lib/action_view/{template_handlers → template/handlers}/builder.rb +6 -6
  147. data/lib/action_view/template/handlers/erb.rb +58 -0
  148. data/lib/action_view/{template_handlers → template/handlers}/rjs.rb +8 -3
  149. data/lib/action_view/template/resolver.rb +164 -0
  150. data/lib/action_view/template/text.rb +40 -0
  151. data/lib/action_view/test_case.rb +18 -18
  152. metadata +165 -420
  153. data/RUNNING_UNIT_TESTS +0 -24
  154. data/Rakefile +0 -158
  155. data/install.rb +0 -30
  156. data/lib/action_controller/assertions/dom_assertions.rb +0 -55
  157. data/lib/action_controller/assertions/response_assertions.rb +0 -169
  158. data/lib/action_controller/benchmarking.rb +0 -107
  159. data/lib/action_controller/caching/sweeper.rb +0 -45
  160. data/lib/action_controller/cgi_ext.rb +0 -15
  161. data/lib/action_controller/cgi_ext/cookie.rb +0 -112
  162. data/lib/action_controller/cgi_ext/query_extension.rb +0 -22
  163. data/lib/action_controller/cgi_ext/stdinput.rb +0 -24
  164. data/lib/action_controller/cgi_process.rb +0 -77
  165. data/lib/action_controller/cookies.rb +0 -197
  166. data/lib/action_controller/dispatcher.rb +0 -133
  167. data/lib/action_controller/failsafe.rb +0 -87
  168. data/lib/action_controller/filters.rb +0 -680
  169. data/lib/action_controller/helpers.rb +0 -225
  170. data/lib/action_controller/layout.rb +0 -286
  171. data/lib/action_controller/middlewares.rb +0 -14
  172. data/lib/action_controller/mime_responds.rb +0 -193
  173. data/lib/action_controller/params_parser.rb +0 -77
  174. data/lib/action_controller/performance_test.rb +0 -15
  175. data/lib/action_controller/rack_lint_patch.rb +0 -36
  176. data/lib/action_controller/reloader.rb +0 -54
  177. data/lib/action_controller/request.rb +0 -518
  178. data/lib/action_controller/request_forgery_protection.rb +0 -116
  179. data/lib/action_controller/rescue.rb +0 -183
  180. data/lib/action_controller/resources.rb +0 -682
  181. data/lib/action_controller/response.rb +0 -237
  182. data/lib/action_controller/routing.rb +0 -388
  183. data/lib/action_controller/routing/builder.rb +0 -197
  184. data/lib/action_controller/routing/optimisations.rb +0 -130
  185. data/lib/action_controller/routing/recognition_optimisation.rb +0 -167
  186. data/lib/action_controller/routing/route.rb +0 -265
  187. data/lib/action_controller/routing/route_set.rb +0 -503
  188. data/lib/action_controller/routing/routing_ext.rb +0 -49
  189. data/lib/action_controller/routing/segments.rb +0 -343
  190. data/lib/action_controller/session/abstract_store.rb +0 -276
  191. data/lib/action_controller/session/mem_cache_store.rb +0 -60
  192. data/lib/action_controller/status_codes.rb +0 -88
  193. data/lib/action_controller/string_coercion.rb +0 -29
  194. data/lib/action_controller/templates/rescues/diagnostics.erb +0 -11
  195. data/lib/action_controller/test_process.rb +0 -580
  196. data/lib/action_controller/uploaded_file.rb +0 -44
  197. data/lib/action_view/helpers/benchmark_helper.rb +0 -54
  198. data/lib/action_view/inline_template.rb +0 -19
  199. data/lib/action_view/reloadable_template.rb +0 -117
  200. data/lib/action_view/renderable.rb +0 -109
  201. data/lib/action_view/renderable_partial.rb +0 -53
  202. data/lib/action_view/template_error.rb +0 -99
  203. data/lib/action_view/template_handler.rb +0 -34
  204. data/lib/action_view/template_handlers.rb +0 -48
  205. data/lib/action_view/template_handlers/erb.rb +0 -25
  206. data/lib/actionpack.rb +0 -2
  207. data/test/abstract_unit.rb +0 -78
  208. data/test/active_record_unit.rb +0 -104
  209. data/test/activerecord/active_record_store_test.rb +0 -221
  210. data/test/activerecord/render_partial_with_record_identification_test.rb +0 -188
  211. data/test/adv_attr_test.rb +0 -20
  212. data/test/controller/action_pack_assertions_test.rb +0 -545
  213. data/test/controller/addresses_render_test.rb +0 -37
  214. data/test/controller/assert_select_test.rb +0 -735
  215. data/test/controller/base_test.rb +0 -217
  216. data/test/controller/benchmark_test.rb +0 -32
  217. data/test/controller/caching_test.rb +0 -743
  218. data/test/controller/capture_test.rb +0 -66
  219. data/test/controller/content_type_test.rb +0 -178
  220. data/test/controller/controller_fixtures/app/controllers/admin/user_controller.rb +0 -0
  221. data/test/controller/controller_fixtures/app/controllers/user_controller.rb +0 -0
  222. data/test/controller/controller_fixtures/vendor/plugins/bad_plugin/lib/plugin_controller.rb +0 -0
  223. data/test/controller/cookie_test.rb +0 -208
  224. data/test/controller/deprecation/deprecated_base_methods_test.rb +0 -32
  225. data/test/controller/dispatcher_test.rb +0 -144
  226. data/test/controller/dom_assertions_test.rb +0 -53
  227. data/test/controller/failsafe_test.rb +0 -60
  228. data/test/controller/fake_controllers.rb +0 -33
  229. data/test/controller/fake_models.rb +0 -19
  230. data/test/controller/filter_params_test.rb +0 -52
  231. data/test/controller/filters_test.rb +0 -885
  232. data/test/controller/flash_test.rb +0 -174
  233. data/test/controller/header_test.rb +0 -14
  234. data/test/controller/helper_test.rb +0 -224
  235. data/test/controller/html-scanner/cdata_node_test.rb +0 -15
  236. data/test/controller/html-scanner/document_test.rb +0 -148
  237. data/test/controller/html-scanner/node_test.rb +0 -89
  238. data/test/controller/html-scanner/sanitizer_test.rb +0 -300
  239. data/test/controller/html-scanner/tag_node_test.rb +0 -238
  240. data/test/controller/html-scanner/text_node_test.rb +0 -50
  241. data/test/controller/html-scanner/tokenizer_test.rb +0 -131
  242. data/test/controller/http_basic_authentication_test.rb +0 -113
  243. data/test/controller/http_digest_authentication_test.rb +0 -254
  244. data/test/controller/integration_test.rb +0 -526
  245. data/test/controller/layout_test.rb +0 -215
  246. data/test/controller/localized_templates_test.rb +0 -24
  247. data/test/controller/logging_test.rb +0 -46
  248. data/test/controller/middleware_stack_test.rb +0 -90
  249. data/test/controller/mime_responds_test.rb +0 -536
  250. data/test/controller/mime_type_test.rb +0 -93
  251. data/test/controller/output_escaping_test.rb +0 -19
  252. data/test/controller/polymorphic_routes_test.rb +0 -297
  253. data/test/controller/rack_test.rb +0 -308
  254. data/test/controller/record_identifier_test.rb +0 -139
  255. data/test/controller/redirect_test.rb +0 -285
  256. data/test/controller/reloader_test.rb +0 -125
  257. data/test/controller/render_test.rb +0 -1783
  258. data/test/controller/request/json_params_parsing_test.rb +0 -65
  259. data/test/controller/request/multipart_params_parsing_test.rb +0 -177
  260. data/test/controller/request/query_string_parsing_test.rb +0 -129
  261. data/test/controller/request/test_request_test.rb +0 -35
  262. data/test/controller/request/url_encoded_params_parsing_test.rb +0 -146
  263. data/test/controller/request/xml_params_parsing_test.rb +0 -103
  264. data/test/controller/request_forgery_protection_test.rb +0 -233
  265. data/test/controller/request_test.rb +0 -398
  266. data/test/controller/rescue_test.rb +0 -541
  267. data/test/controller/resources_test.rb +0 -1393
  268. data/test/controller/routing_test.rb +0 -2592
  269. data/test/controller/selector_test.rb +0 -628
  270. data/test/controller/send_file_test.rb +0 -171
  271. data/test/controller/session/abstract_store_test.rb +0 -64
  272. data/test/controller/session/cookie_store_test.rb +0 -354
  273. data/test/controller/session/mem_cache_store_test.rb +0 -187
  274. data/test/controller/session/test_session_test.rb +0 -58
  275. data/test/controller/test_test.rb +0 -700
  276. data/test/controller/translation_test.rb +0 -26
  277. data/test/controller/url_rewriter_test.rb +0 -395
  278. data/test/controller/verification_test.rb +0 -270
  279. data/test/controller/view_paths_test.rb +0 -141
  280. data/test/controller/webservice_test.rb +0 -273
  281. data/test/fixtures/_top_level_partial.html.erb +0 -1
  282. data/test/fixtures/_top_level_partial_only.erb +0 -1
  283. data/test/fixtures/addresses/list.erb +0 -1
  284. data/test/fixtures/alternate_helpers/foo_helper.rb +0 -3
  285. data/test/fixtures/bad_customers/_bad_customer.html.erb +0 -1
  286. data/test/fixtures/companies.yml +0 -24
  287. data/test/fixtures/company.rb +0 -10
  288. data/test/fixtures/content_type/render_default_content_types_for_respond_to.rhtml +0 -1
  289. data/test/fixtures/content_type/render_default_for_rhtml.rhtml +0 -1
  290. data/test/fixtures/content_type/render_default_for_rjs.rjs +0 -1
  291. data/test/fixtures/content_type/render_default_for_rxml.rxml +0 -1
  292. data/test/fixtures/customers/_customer.html.erb +0 -1
  293. data/test/fixtures/db_definitions/sqlite.sql +0 -49
  294. data/test/fixtures/developer.rb +0 -9
  295. data/test/fixtures/developers.yml +0 -21
  296. data/test/fixtures/developers/_developer.erb +0 -1
  297. data/test/fixtures/developers_projects.yml +0 -13
  298. data/test/fixtures/failsafe/500.html +0 -1
  299. data/test/fixtures/fun/games/_game.erb +0 -1
  300. data/test/fixtures/fun/games/hello_world.erb +0 -1
  301. data/test/fixtures/fun/serious/games/_game.erb +0 -1
  302. data/test/fixtures/functional_caching/_partial.erb +0 -3
  303. data/test/fixtures/functional_caching/formatted_fragment_cached.html.erb +0 -3
  304. data/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs +0 -6
  305. data/test/fixtures/functional_caching/formatted_fragment_cached.xml.builder +0 -5
  306. data/test/fixtures/functional_caching/fragment_cached.html.erb +0 -2
  307. data/test/fixtures/functional_caching/html_fragment_cached_with_partial.html.erb +0 -1
  308. data/test/fixtures/functional_caching/inline_fragment_cached.html.erb +0 -2
  309. data/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs +0 -1
  310. data/test/fixtures/good_customers/_good_customer.html.erb +0 -1
  311. data/test/fixtures/helpers/abc_helper.rb +0 -5
  312. data/test/fixtures/helpers/fun/games_helper.rb +0 -3
  313. data/test/fixtures/helpers/fun/pdf_helper.rb +0 -3
  314. data/test/fixtures/layout_tests/abs_path_layout.rhtml +0 -1
  315. data/test/fixtures/layout_tests/alt/hello.rhtml +0 -1
  316. data/test/fixtures/layout_tests/alt/layouts/alt.rhtml +0 -0
  317. data/test/fixtures/layout_tests/layouts/controller_name_space/nested.rhtml +0 -1
  318. data/test/fixtures/layout_tests/layouts/item.rhtml +0 -1
  319. data/test/fixtures/layout_tests/layouts/layout_test.rhtml +0 -1
  320. data/test/fixtures/layout_tests/layouts/multiple_extensions.html.erb +0 -1
  321. data/test/fixtures/layout_tests/layouts/third_party_template_library.mab +0 -1
  322. data/test/fixtures/layout_tests/views/hello.rhtml +0 -1
  323. data/test/fixtures/layouts/_column.html.erb +0 -2
  324. data/test/fixtures/layouts/block_with_layout.erb +0 -3
  325. data/test/fixtures/layouts/builder.builder +0 -3
  326. data/test/fixtures/layouts/default_html.html.erb +0 -1
  327. data/test/fixtures/layouts/partial_with_layout.erb +0 -3
  328. data/test/fixtures/layouts/standard.erb +0 -1
  329. data/test/fixtures/layouts/talk_from_action.erb +0 -2
  330. data/test/fixtures/layouts/xhr.html.erb +0 -2
  331. data/test/fixtures/layouts/yield.erb +0 -2
  332. data/test/fixtures/localized/hello_world.de.html +0 -1
  333. data/test/fixtures/localized/hello_world.en.html +0 -1
  334. data/test/fixtures/mascot.rb +0 -3
  335. data/test/fixtures/mascots.yml +0 -4
  336. data/test/fixtures/mascots/_mascot.html.erb +0 -1
  337. data/test/fixtures/multipart/binary_file +0 -0
  338. data/test/fixtures/multipart/boundary_problem_file +0 -10
  339. data/test/fixtures/multipart/bracketed_param +0 -5
  340. data/test/fixtures/multipart/empty +0 -10
  341. data/test/fixtures/multipart/hello.txt +0 -1
  342. data/test/fixtures/multipart/large_text_file +0 -10
  343. data/test/fixtures/multipart/mixed_files +0 -0
  344. data/test/fixtures/multipart/mona_lisa.jpg +0 -0
  345. data/test/fixtures/multipart/none +0 -9
  346. data/test/fixtures/multipart/single_parameter +0 -5
  347. data/test/fixtures/multipart/text_file +0 -10
  348. data/test/fixtures/override/test/hello_world.erb +0 -1
  349. data/test/fixtures/override2/layouts/test/sub.erb +0 -1
  350. data/test/fixtures/post_test/layouts/post.html.erb +0 -1
  351. data/test/fixtures/post_test/layouts/super_post.iphone.erb +0 -1
  352. data/test/fixtures/post_test/post/index.html.erb +0 -1
  353. data/test/fixtures/post_test/post/index.iphone.erb +0 -1
  354. data/test/fixtures/post_test/super_post/index.html.erb +0 -1
  355. data/test/fixtures/post_test/super_post/index.iphone.erb +0 -1
  356. data/test/fixtures/project.rb +0 -3
  357. data/test/fixtures/projects.yml +0 -7
  358. data/test/fixtures/projects/_project.erb +0 -1
  359. data/test/fixtures/public/404.html +0 -1
  360. data/test/fixtures/public/500.da.html +0 -1
  361. data/test/fixtures/public/500.html +0 -1
  362. data/test/fixtures/public/absolute/test.css +0 -23
  363. data/test/fixtures/public/absolute/test.js +0 -63
  364. data/test/fixtures/public/images/rails.png +0 -0
  365. data/test/fixtures/public/javascripts/application.js +0 -1
  366. data/test/fixtures/public/javascripts/bank.js +0 -1
  367. data/test/fixtures/public/javascripts/controls.js +0 -1
  368. data/test/fixtures/public/javascripts/dragdrop.js +0 -1
  369. data/test/fixtures/public/javascripts/effects.js +0 -1
  370. data/test/fixtures/public/javascripts/prototype.js +0 -1
  371. data/test/fixtures/public/javascripts/robber.js +0 -1
  372. data/test/fixtures/public/javascripts/subdir/subdir.js +0 -1
  373. data/test/fixtures/public/javascripts/version.1.0.js +0 -1
  374. data/test/fixtures/public/stylesheets/bank.css +0 -1
  375. data/test/fixtures/public/stylesheets/robber.css +0 -1
  376. data/test/fixtures/public/stylesheets/subdir/subdir.css +0 -1
  377. data/test/fixtures/public/stylesheets/version.1.0.css +0 -1
  378. data/test/fixtures/quiz/questions/_question.html.erb +0 -1
  379. data/test/fixtures/replies.yml +0 -15
  380. data/test/fixtures/replies/_reply.erb +0 -1
  381. data/test/fixtures/reply.rb +0 -7
  382. data/test/fixtures/respond_to/all_types_with_layout.html.erb +0 -1
  383. data/test/fixtures/respond_to/all_types_with_layout.js.rjs +0 -1
  384. data/test/fixtures/respond_to/custom_constant_handling_without_block.mobile.erb +0 -1
  385. data/test/fixtures/respond_to/iphone_with_html_response_type.html.erb +0 -1
  386. data/test/fixtures/respond_to/iphone_with_html_response_type.iphone.erb +0 -1
  387. data/test/fixtures/respond_to/layouts/missing.html.erb +0 -1
  388. data/test/fixtures/respond_to/layouts/standard.html.erb +0 -1
  389. data/test/fixtures/respond_to/layouts/standard.iphone.erb +0 -1
  390. data/test/fixtures/respond_to/using_defaults.html.erb +0 -1
  391. data/test/fixtures/respond_to/using_defaults.js.rjs +0 -1
  392. data/test/fixtures/respond_to/using_defaults.xml.builder +0 -1
  393. data/test/fixtures/respond_to/using_defaults_with_type_list.html.erb +0 -1
  394. data/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs +0 -1
  395. data/test/fixtures/respond_to/using_defaults_with_type_list.xml.builder +0 -1
  396. data/test/fixtures/scope/test/modgreet.erb +0 -1
  397. data/test/fixtures/session_autoload_test/session_autoload_test/foo.rb +0 -10
  398. data/test/fixtures/shared.html.erb +0 -1
  399. data/test/fixtures/symlink_parent/symlinked_layout.erb +0 -5
  400. data/test/fixtures/test/_counter.html.erb +0 -1
  401. data/test/fixtures/test/_customer.erb +0 -1
  402. data/test/fixtures/test/_customer_counter.erb +0 -1
  403. data/test/fixtures/test/_customer_counter_with_as.erb +0 -1
  404. data/test/fixtures/test/_customer_greeting.erb +0 -1
  405. data/test/fixtures/test/_customer_with_var.erb +0 -1
  406. data/test/fixtures/test/_form.erb +0 -1
  407. data/test/fixtures/test/_from_helper.erb +0 -1
  408. data/test/fixtures/test/_hash_greeting.erb +0 -1
  409. data/test/fixtures/test/_hash_object.erb +0 -2
  410. data/test/fixtures/test/_hello.builder +0 -1
  411. data/test/fixtures/test/_labelling_form.erb +0 -1
  412. data/test/fixtures/test/_layout_for_block_with_args.html.erb +0 -3
  413. data/test/fixtures/test/_layout_for_partial.html.erb +0 -3
  414. data/test/fixtures/test/_local_inspector.html.erb +0 -1
  415. data/test/fixtures/test/_one.html.erb +0 -1
  416. data/test/fixtures/test/_partial.erb +0 -1
  417. data/test/fixtures/test/_partial.html.erb +0 -1
  418. data/test/fixtures/test/_partial.js.erb +0 -1
  419. data/test/fixtures/test/_partial_for_use_in_layout.html.erb +0 -1
  420. data/test/fixtures/test/_partial_only.erb +0 -1
  421. data/test/fixtures/test/_partial_with_only_html_version.html.erb +0 -1
  422. data/test/fixtures/test/_person.erb +0 -2
  423. data/test/fixtures/test/_raise.html.erb +0 -1
  424. data/test/fixtures/test/_two.html.erb +0 -1
  425. data/test/fixtures/test/_utf8_partial.html.erb +0 -1
  426. data/test/fixtures/test/_utf8_partial_magic.html.erb +0 -2
  427. data/test/fixtures/test/action_talk_to_layout.erb +0 -2
  428. data/test/fixtures/test/array_translation.erb +0 -1
  429. data/test/fixtures/test/calling_partial_with_layout.html.erb +0 -1
  430. data/test/fixtures/test/capturing.erb +0 -4
  431. data/test/fixtures/test/content_for.erb +0 -2
  432. data/test/fixtures/test/content_for_concatenated.erb +0 -3
  433. data/test/fixtures/test/content_for_with_parameter.erb +0 -2
  434. data/test/fixtures/test/delete_with_js.rjs +0 -2
  435. data/test/fixtures/test/dont_pick_me +0 -1
  436. data/test/fixtures/test/dot.directory/render_file_with_ivar.erb +0 -1
  437. data/test/fixtures/test/enum_rjs_test.rjs +0 -6
  438. data/test/fixtures/test/formatted_html_erb.html.erb +0 -1
  439. data/test/fixtures/test/formatted_xml_erb.builder +0 -1
  440. data/test/fixtures/test/formatted_xml_erb.html.erb +0 -1
  441. data/test/fixtures/test/formatted_xml_erb.xml.erb +0 -1
  442. data/test/fixtures/test/greeting.erb +0 -1
  443. data/test/fixtures/test/greeting.js.rjs +0 -1
  444. data/test/fixtures/test/hello.builder +0 -4
  445. data/test/fixtures/test/hello_world.da.html.erb +0 -1
  446. data/test/fixtures/test/hello_world.erb +0 -1
  447. data/test/fixtures/test/hello_world.erb~ +0 -1
  448. data/test/fixtures/test/hello_world.pt-BR.html.erb +0 -1
  449. data/test/fixtures/test/hello_world_container.builder +0 -3
  450. data/test/fixtures/test/hello_world_from_rxml.builder +0 -4
  451. data/test/fixtures/test/hello_world_with_layout_false.erb +0 -1
  452. data/test/fixtures/test/hello_xml_world.builder +0 -11
  453. data/test/fixtures/test/hyphen-ated.erb +0 -1
  454. data/test/fixtures/test/implicit_content_type.atom.builder +0 -2
  455. data/test/fixtures/test/list.erb +0 -1
  456. data/test/fixtures/test/malformed/malformed.en.html.erb~ +0 -1
  457. data/test/fixtures/test/malformed/malformed.erb~ +0 -1
  458. data/test/fixtures/test/malformed/malformed.html.erb~ +0 -1
  459. data/test/fixtures/test/nested_layout.erb +0 -3
  460. data/test/fixtures/test/non_erb_block_content_for.builder +0 -4
  461. data/test/fixtures/test/potential_conflicts.erb +0 -4
  462. data/test/fixtures/test/render_explicit_html_template.js.rjs +0 -1
  463. data/test/fixtures/test/render_file_from_template.html.erb +0 -1
  464. data/test/fixtures/test/render_file_with_ivar.erb +0 -1
  465. data/test/fixtures/test/render_file_with_locals.erb +0 -1
  466. data/test/fixtures/test/render_implicit_html_template.js.rjs +0 -1
  467. data/test/fixtures/test/render_implicit_html_template_from_xhr_request.da.html.erb +0 -1
  468. data/test/fixtures/test/render_implicit_html_template_from_xhr_request.html.erb +0 -1
  469. data/test/fixtures/test/render_implicit_js_template_without_layout.js.erb +0 -1
  470. data/test/fixtures/test/render_to_string_test.erb +0 -1
  471. data/test/fixtures/test/scoped_array_translation.erb +0 -1
  472. data/test/fixtures/test/sub_template_raise.html.erb +0 -1
  473. data/test/fixtures/test/template.erb +0 -1
  474. data/test/fixtures/test/translation.erb +0 -1
  475. data/test/fixtures/test/update_element_with_capture.erb +0 -9
  476. data/test/fixtures/test/using_layout_around_block.html.erb +0 -1
  477. data/test/fixtures/test/using_layout_around_block_with_args.html.erb +0 -1
  478. data/test/fixtures/test/utf8.html.erb +0 -4
  479. data/test/fixtures/test/utf8_magic.html.erb +0 -5
  480. data/test/fixtures/test/utf8_magic_with_bare_partial.html.erb +0 -5
  481. data/test/fixtures/topic.rb +0 -3
  482. data/test/fixtures/topics.yml +0 -22
  483. data/test/fixtures/topics/_topic.html.erb +0 -1
  484. data/test/template/active_record_helper_i18n_test.rb +0 -51
  485. data/test/template/active_record_helper_test.rb +0 -302
  486. data/test/template/asset_tag_helper_test.rb +0 -770
  487. data/test/template/atom_feed_helper_test.rb +0 -315
  488. data/test/template/benchmark_helper_test.rb +0 -86
  489. data/test/template/compiled_templates_test.rb +0 -204
  490. data/test/template/date_helper_i18n_test.rb +0 -121
  491. data/test/template/date_helper_test.rb +0 -2603
  492. data/test/template/erb_util_test.rb +0 -36
  493. data/test/template/form_helper_test.rb +0 -1447
  494. data/test/template/form_options_helper_i18n_test.rb +0 -27
  495. data/test/template/form_options_helper_test.rb +0 -811
  496. data/test/template/form_tag_helper_test.rb +0 -356
  497. data/test/template/javascript_helper_test.rb +0 -106
  498. data/test/template/number_helper_i18n_test.rb +0 -69
  499. data/test/template/number_helper_test.rb +0 -132
  500. data/test/template/prototype_helper_test.rb +0 -639
  501. data/test/template/raw_output_helper_test.rb +0 -21
  502. data/test/template/record_tag_helper_test.rb +0 -58
  503. data/test/template/render_test.rb +0 -329
  504. data/test/template/sanitize_helper_test.rb +0 -57
  505. data/test/template/scriptaculous_helper_test.rb +0 -90
  506. data/test/template/tag_helper_test.rb +0 -98
  507. data/test/template/template_test.rb +0 -32
  508. data/test/template/test_test.rb +0 -54
  509. data/test/template/text_helper_test.rb +0 -601
  510. data/test/template/translation_helper_test.rb +0 -95
  511. data/test/template/url_helper_test.rb +0 -641
  512. data/test/testing_sandbox.rb +0 -15
  513. data/test/view/test_case_test.rb +0 -176
@@ -1,1425 +1,93 @@
1
- require 'set'
2
-
3
- module ActionController #:nodoc:
4
- class ActionControllerError < StandardError #:nodoc:
5
- end
6
-
7
- class SessionRestoreError < ActionControllerError #:nodoc:
8
- end
9
-
10
- class RenderError < ActionControllerError #:nodoc:
11
- end
12
-
13
- class RoutingError < ActionControllerError #:nodoc:
14
- attr_reader :failures
15
- def initialize(message, failures=[])
16
- super(message)
17
- @failures = failures
18
- end
19
- end
20
-
21
- class MethodNotAllowed < ActionControllerError #:nodoc:
22
- attr_reader :allowed_methods
23
-
24
- def initialize(*allowed_methods)
25
- super("Only #{allowed_methods.to_sentence(:locale => :en)} requests are allowed.")
26
- @allowed_methods = allowed_methods
27
- end
28
-
29
- def allowed_methods_header
30
- allowed_methods.map { |method_symbol| method_symbol.to_s.upcase } * ', '
31
- end
32
-
33
- def handle_response!(response)
34
- response.headers['Allow'] ||= allowed_methods_header
35
- end
36
- end
37
-
38
- class NotImplemented < MethodNotAllowed #:nodoc:
39
- end
40
-
41
- class UnknownController < ActionControllerError #:nodoc:
42
- end
43
-
44
- class UnknownAction < ActionControllerError #:nodoc:
45
- end
46
-
47
- class MissingFile < ActionControllerError #:nodoc:
48
- end
49
-
50
- class RenderError < ActionControllerError #:nodoc:
51
- end
52
-
53
- class SessionOverflowError < ActionControllerError #:nodoc:
54
- DEFAULT_MESSAGE = 'Your session data is larger than the data column in which it is to be stored. You must increase the size of your data column if you intend to store large data.'
55
-
56
- def initialize(message = nil)
57
- super(message || DEFAULT_MESSAGE)
58
- end
59
- end
60
-
61
- class DoubleRenderError < ActionControllerError #:nodoc:
62
- DEFAULT_MESSAGE = "Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like \"redirect_to(...) and return\"."
63
-
64
- def initialize(message = nil)
65
- super(message || DEFAULT_MESSAGE)
66
- end
67
- end
68
-
69
- class RedirectBackError < ActionControllerError #:nodoc:
70
- DEFAULT_MESSAGE = 'No HTTP_REFERER was set in the request to this action, so redirect_to :back could not be called successfully. If this is a test, make sure to specify request.env["HTTP_REFERER"].'
71
-
72
- def initialize(message = nil)
73
- super(message || DEFAULT_MESSAGE)
74
- end
75
- end
76
-
77
- class UnknownHttpMethod < ActionControllerError #:nodoc:
78
- end
79
-
80
- # Action Controllers are the core of a web request in Rails. They are made up of one or more actions that are executed
81
- # on request and then either render a template or redirect to another action. An action is defined as a public method
82
- # on the controller, which will automatically be made accessible to the web-server through Rails Routes.
83
- #
84
- # A sample controller could look like this:
85
- #
86
- # class GuestBookController < ActionController::Base
87
- # def index
88
- # @entries = Entry.find(:all)
89
- # end
90
- #
91
- # def sign
92
- # Entry.create(params[:entry])
93
- # redirect_to :action => "index"
94
- # end
95
- # end
96
- #
97
- # Actions, by default, render a template in the <tt>app/views</tt> directory corresponding to the name of the controller and action
98
- # after executing code in the action. For example, the +index+ action of the GuestBookController would render the
99
- # template <tt>app/views/guestbook/index.erb</tt> by default after populating the <tt>@entries</tt> instance variable.
100
- #
101
- # Unlike index, the sign action will not render a template. After performing its main purpose (creating a
102
- # new entry in the guest book), it initiates a redirect instead. This redirect works by returning an external
103
- # "302 Moved" HTTP response that takes the user to the index action.
104
- #
105
- # The index and sign represent the two basic action archetypes used in Action Controllers. Get-and-show and do-and-redirect.
106
- # Most actions are variations of these themes.
107
- #
108
- # == Requests
109
- #
110
- # Requests are processed by the Action Controller framework by extracting the value of the "action" key in the request parameters.
111
- # This value should hold the name of the action to be performed. Once the action has been identified, the remaining
112
- # request parameters, the session (if one is available), and the full request with all the HTTP headers are made available to
113
- # the action through instance variables. Then the action is performed.
114
- #
115
- # The full request object is available with the request accessor and is primarily used to query for HTTP headers. These queries
116
- # are made by accessing the environment hash, like this:
117
- #
118
- # def server_ip
119
- # location = request.env["SERVER_ADDR"]
120
- # render :text => "This server hosted at #{location}"
121
- # end
122
- #
123
- # == Parameters
124
- #
125
- # All request parameters, whether they come from a GET or POST request, or from the URL, are available through the params method
126
- # which returns a hash. For example, an action that was performed through <tt>/weblog/list?category=All&limit=5</tt> will include
127
- # <tt>{ "category" => "All", "limit" => 5 }</tt> in params.
128
- #
129
- # It's also possible to construct multi-dimensional parameter hashes by specifying keys using brackets, such as:
130
- #
131
- # <input type="text" name="post[name]" value="david">
132
- # <input type="text" name="post[address]" value="hyacintvej">
133
- #
134
- # A request stemming from a form holding these inputs will include <tt>{ "post" => { "name" => "david", "address" => "hyacintvej" } }</tt>.
135
- # If the address input had been named "post[address][street]", the params would have included
136
- # <tt>{ "post" => { "address" => { "street" => "hyacintvej" } } }</tt>. There's no limit to the depth of the nesting.
137
- #
138
- # == Sessions
139
- #
140
- # Sessions allows you to store objects in between requests. This is useful for objects that are not yet ready to be persisted,
141
- # such as a Signup object constructed in a multi-paged process, or objects that don't change much and are needed all the time, such
142
- # as a User object for a system that requires login. The session should not be used, however, as a cache for objects where it's likely
143
- # they could be changed unknowingly. It's usually too much work to keep it all synchronized -- something databases already excel at.
144
- #
145
- # You can place objects in the session by using the <tt>session</tt> method, which accesses a hash:
146
- #
147
- # session[:person] = Person.authenticate(user_name, password)
148
- #
149
- # And retrieved again through the same hash:
150
- #
151
- # Hello #{session[:person]}
152
- #
153
- # For removing objects from the session, you can either assign a single key to +nil+:
154
- #
155
- # # removes :person from session
156
- # session[:person] = nil
157
- #
158
- # or you can remove the entire session with +reset_session+.
159
- #
160
- # Sessions are stored by default in a browser cookie that's cryptographically signed, but unencrypted.
161
- # This prevents the user from tampering with the session but also allows him to see its contents.
162
- #
163
- # Do not put secret information in cookie-based sessions!
164
- #
165
- # Other options for session storage are:
166
- #
167
- # * ActiveRecord::SessionStore - Sessions are stored in your database, which works better than PStore with multiple app servers and,
168
- # unlike CookieStore, hides your session contents from the user. To use ActiveRecord::SessionStore, set
169
- #
170
- # config.action_controller.session_store = :active_record_store
171
- #
172
- # in your <tt>config/environment.rb</tt> and run <tt>rake db:sessions:create</tt>.
173
- #
174
- # * MemCacheStore - Sessions are stored as entries in your memcached cache.
175
- # Set the session store type in <tt>config/environment.rb</tt>:
176
- #
177
- # config.action_controller.session_store = :mem_cache_store
178
- #
179
- # This assumes that memcached has been installed and configured properly.
180
- # See the MemCacheStore docs for more information.
181
- #
182
- # == Responses
183
- #
184
- # Each action results in a response, which holds the headers and document to be sent to the user's browser. The actual response
185
- # object is generated automatically through the use of renders and redirects and requires no user intervention.
186
- #
187
- # == Renders
188
- #
189
- # Action Controller sends content to the user by using one of five rendering methods. The most versatile and common is the rendering
190
- # of a template. Included in the Action Pack is the Action View, which enables rendering of ERb templates. It's automatically configured.
191
- # The controller passes objects to the view by assigning instance variables:
192
- #
193
- # def show
194
- # @post = Post.find(params[:id])
195
- # end
196
- #
197
- # Which are then automatically available to the view:
198
- #
199
- # Title: <%= @post.title %>
200
- #
201
- # You don't have to rely on the automated rendering. Especially actions that could result in the rendering of different templates will use
202
- # the manual rendering methods:
203
- #
204
- # def search
205
- # @results = Search.find(params[:query])
206
- # case @results
207
- # when 0 then render :action => "no_results"
208
- # when 1 then render :action => "show"
209
- # when 2..10 then render :action => "show_many"
210
- # end
211
- # end
212
- #
213
- # Read more about writing ERb and Builder templates in link:classes/ActionView/Base.html.
214
- #
215
- # == Redirects
216
- #
217
- # Redirects are used to move from one action to another. For example, after a <tt>create</tt> action, which stores a blog entry to a database,
218
- # we might like to show the user the new entry. Because we're following good DRY principles (Don't Repeat Yourself), we're going to reuse (and redirect to)
219
- # a <tt>show</tt> action that we'll assume has already been created. The code might look like this:
220
- #
221
- # def create
222
- # @entry = Entry.new(params[:entry])
223
- # if @entry.save
224
- # # The entry was saved correctly, redirect to show
225
- # redirect_to :action => 'show', :id => @entry.id
226
- # else
227
- # # things didn't go so well, do something else
228
- # end
229
- # end
230
- #
231
- # In this case, after saving our new entry to the database, the user is redirected to the <tt>show</tt> method which is then executed.
232
- #
233
- # == Calling multiple redirects or renders
234
- #
235
- # An action may contain only a single render or a single redirect. Attempting to try to do either again will result in a DoubleRenderError:
236
- #
237
- # def do_something
238
- # redirect_to :action => "elsewhere"
239
- # render :action => "overthere" # raises DoubleRenderError
240
- # end
241
- #
242
- # If you need to redirect on the condition of something, then be sure to add "and return" to halt execution.
243
- #
244
- # def do_something
245
- # redirect_to(:action => "elsewhere") and return if monkeys.nil?
246
- # render :action => "overthere" # won't be called if monkeys is nil
247
- # end
248
- #
249
- class Base
250
- DEFAULT_RENDER_STATUS_CODE = "200 OK"
251
-
252
- include StatusCodes
253
-
254
- cattr_reader :protected_instance_variables
255
- # Controller specific instance variables which will not be accessible inside views.
256
- @@protected_instance_variables = %w(@assigns @performed_redirect @performed_render @variables_added @request_origin @url @parent_controller
257
- @action_name @before_filter_chain_aborted @action_cache_path @_session @_headers @_params
258
- @_flash @_response)
259
-
260
- # Prepends all the URL-generating helpers from AssetHelper. This makes it possible to easily move javascripts, stylesheets,
261
- # and images to a dedicated asset server away from the main web server. Example:
262
- # ActionController::Base.asset_host = "http://assets.example.com"
263
- @@asset_host = ""
264
- cattr_accessor :asset_host
265
-
266
- # All requests are considered local by default, so everyone will be exposed to detailed debugging screens on errors.
267
- # When the application is ready to go public, this should be set to false, and the protected method <tt>local_request?</tt>
268
- # should instead be implemented in the controller to determine when debugging screens should be shown.
269
- @@consider_all_requests_local = true
270
- cattr_accessor :consider_all_requests_local
271
-
272
- # Indicates whether to allow concurrent action processing. Your
273
- # controller actions and any other code they call must also behave well
274
- # when called from concurrent threads. Turned off by default.
275
- @@allow_concurrency = false
276
- cattr_accessor :allow_concurrency
277
-
278
- # Modern REST web services often need to submit complex data to the web application.
279
- # The <tt>@@param_parsers</tt> hash lets you register handlers which will process the HTTP body and add parameters to the
280
- # <tt>params</tt> hash. These handlers are invoked for POST and PUT requests.
281
- #
282
- # By default <tt>application/xml</tt> is enabled. A XmlSimple class with the same param name as the root will be instantiated
283
- # in the <tt>params</tt>. This allows XML requests to mask themselves as regular form submissions, so you can have one
284
- # action serve both regular forms and web service requests.
285
- #
286
- # Example of doing your own parser for a custom content type:
287
- #
288
- # ActionController::Base.param_parsers[Mime::Type.lookup('application/atom+xml')] = Proc.new do |data|
289
- # node = REXML::Document.new(post)
290
- # { node.root.name => node.root }
291
- # end
292
- #
293
- # Note: Up until release 1.1 of Rails, Action Controller would default to using XmlSimple configured to discard the
294
- # root node for such requests. The new default is to keep the root, such that "<r><name>David</name></r>" results
295
- # in <tt>params[:r][:name]</tt> for "David" instead of <tt>params[:name]</tt>. To get the old behavior, you can
296
- # re-register XmlSimple as application/xml handler ike this:
297
- #
298
- # ActionController::Base.param_parsers[Mime::XML] =
299
- # Proc.new { |data| XmlSimple.xml_in(data, 'ForceArray' => false) }
300
- #
301
- # A YAML parser is also available and can be turned on with:
302
- #
303
- # ActionController::Base.param_parsers[Mime::YAML] = :yaml
304
- @@param_parsers = {}
305
- cattr_accessor :param_parsers
306
-
307
- # Controls the default charset for all renders.
308
- @@default_charset = "utf-8"
309
- cattr_accessor :default_charset
310
-
311
- # The logger is used for generating information on the action run-time (including benchmarking) if available.
312
- # Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers.
313
- cattr_accessor :logger
314
-
315
- # Controls the resource action separator
316
- @@resource_action_separator = "/"
317
- cattr_accessor :resource_action_separator
318
-
319
- # Allow to override path names for default resources' actions
320
- @@resources_path_names = { :new => 'new', :edit => 'edit' }
321
- cattr_accessor :resources_path_names
322
-
323
- # Sets the token parameter name for RequestForgery. Calling +protect_from_forgery+
324
- # sets it to <tt>:authenticity_token</tt> by default.
325
- cattr_accessor :request_forgery_protection_token
326
-
327
- # Controls the IP Spoofing check when determining the remote IP.
328
- @@ip_spoofing_check = true
329
- cattr_accessor :ip_spoofing_check
330
-
331
- # Indicates whether or not optimise the generated named
332
- # route helper methods
333
- cattr_accessor :optimise_named_routes
334
- self.optimise_named_routes = true
335
-
336
- # Indicates whether the response format should be determined by examining the Accept HTTP header,
337
- # or by using the simpler params + ajax rules.
338
- #
339
- # If this is set to +true+ (the default) then +respond_to+ and +Request#format+ will take the Accept
340
- # header into account. If it is set to false then the request format will be determined solely
341
- # by examining params[:format]. If params format is missing, the format will be either HTML or
342
- # Javascript depending on whether the request is an AJAX request.
343
- cattr_accessor :use_accept_header
344
- self.use_accept_header = true
345
-
346
- # Controls whether request forgergy protection is turned on or not. Turned off by default only in test mode.
347
- class_inheritable_accessor :allow_forgery_protection
348
- self.allow_forgery_protection = true
349
-
350
- # If you are deploying to a subdirectory, you will need to set
351
- # <tt>config.action_controller.relative_url_root</tt>
352
- # This defaults to ENV['RAILS_RELATIVE_URL_ROOT']
353
- cattr_accessor :relative_url_root
354
- self.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT']
355
-
356
- # Holds the request object that's primarily used to get environment variables through access like
357
- # <tt>request.env["REQUEST_URI"]</tt>.
358
- attr_internal :request
359
-
360
- # Holds a hash of all the GET, POST, and Url parameters passed to the action. Accessed like <tt>params["post_id"]</tt>
361
- # to get the post_id. No type casts are made, so all values are returned as strings.
362
- attr_internal :params
363
-
364
- # Holds the response object that's primarily used to set additional HTTP headers through access like
365
- # <tt>response.headers["Cache-Control"] = "no-cache"</tt>. Can also be used to access the final body HTML after a template
366
- # has been rendered through response.body -- useful for <tt>after_filter</tt>s that wants to manipulate the output,
367
- # such as a OutputCompressionFilter.
368
- attr_internal :response
369
-
370
- # Holds a hash of objects in the session. Accessed like <tt>session[:person]</tt> to get the object tied to the "person"
371
- # key. The session will hold any type of object as values, but the key should be a string or symbol.
372
- attr_internal :session
373
-
374
- # Holds a hash of header names and values. Accessed like <tt>headers["Cache-Control"]</tt> to get the value of the Cache-Control
375
- # directive. Values should always be specified as strings.
376
- attr_internal :headers
377
-
378
- # Returns the name of the action this controller is processing.
379
- attr_accessor :action_name
380
-
381
- class << self
382
- def call(env)
383
- # HACK: For global rescue to have access to the original request and response
384
- request = env["action_controller.rescue.request"] ||= Request.new(env)
385
- response = env["action_controller.rescue.response"] ||= Response.new
386
- process(request, response)
387
- end
388
-
389
- # Factory for the standard create, process loop where the controller is discarded after processing.
390
- def process(request, response) #:nodoc:
391
- new.process(request, response)
392
- end
393
-
394
- # Converts the class name from something like "OneModule::TwoModule::NeatController" to "NeatController".
395
- def controller_class_name
396
- @controller_class_name ||= name.demodulize
397
- end
398
-
399
- # Converts the class name from something like "OneModule::TwoModule::NeatController" to "neat".
400
- def controller_name
401
- @controller_name ||= controller_class_name.sub(/Controller$/, '').underscore
402
- end
403
-
404
- # Converts the class name from something like "OneModule::TwoModule::NeatController" to "one_module/two_module/neat".
405
- def controller_path
406
- @controller_path ||= name.gsub(/Controller$/, '').underscore
407
- end
408
-
409
- # Return an array containing the names of public methods that have been marked hidden from the action processor.
410
- # By default, all methods defined in ActionController::Base and included modules are hidden.
411
- # More methods can be hidden using <tt>hide_actions</tt>.
412
- def hidden_actions
413
- read_inheritable_attribute(:hidden_actions) || write_inheritable_attribute(:hidden_actions, [])
414
- end
415
-
416
- # Hide each of the given methods from being callable as actions.
417
- def hide_action(*names)
418
- write_inheritable_attribute(:hidden_actions, hidden_actions | names.map { |name| name.to_s })
419
- end
420
-
421
- # View load paths determine the bases from which template references can be made. So a call to
422
- # render("test/template") will be looked up in the view load paths array and the closest match will be
423
- # returned.
424
- def view_paths
425
- if defined? @view_paths
426
- @view_paths
427
- else
428
- superclass.view_paths
429
- end
430
- end
431
-
432
- def view_paths=(value)
433
- @view_paths = ActionView::Base.process_view_paths(value) if value
434
- end
435
-
436
- # Adds a view_path to the front of the view_paths array.
437
- # If the current class has no view paths, copy them from
438
- # the superclass. This change will be visible for all future requests.
439
- #
440
- # ArticleController.prepend_view_path("views/default")
441
- # ArticleController.prepend_view_path(["views/default", "views/custom"])
442
- #
443
- def prepend_view_path(path)
444
- @view_paths = superclass.view_paths.dup if !defined?(@view_paths) || @view_paths.nil?
445
- @view_paths.unshift(*path)
446
- end
447
-
448
- # Adds a view_path to the end of the view_paths array.
449
- # If the current class has no view paths, copy them from
450
- # the superclass. This change will be visible for all future requests.
451
- #
452
- # ArticleController.append_view_path("views/default")
453
- # ArticleController.append_view_path(["views/default", "views/custom"])
454
- #
455
- def append_view_path(path)
456
- @view_paths = superclass.view_paths.dup if @view_paths.nil?
457
- @view_paths.push(*path)
458
- end
459
-
460
- # Replace sensitive parameter data from the request log.
461
- # Filters parameters that have any of the arguments as a substring.
462
- # Looks in all subhashes of the param hash for keys to filter.
463
- # If a block is given, each key and value of the parameter hash and all
464
- # subhashes is passed to it, the value or key
465
- # can be replaced using String#replace or similar method.
466
- #
467
- # Examples:
468
- # filter_parameter_logging
469
- # => Does nothing, just slows the logging process down
470
- #
471
- # filter_parameter_logging :password
472
- # => replaces the value to all keys matching /password/i with "[FILTERED]"
473
- #
474
- # filter_parameter_logging :foo, "bar"
475
- # => replaces the value to all keys matching /foo|bar/i with "[FILTERED]"
476
- #
477
- # filter_parameter_logging { |k,v| v.reverse! if k =~ /secret/i }
478
- # => reverses the value to all keys matching /secret/i
479
- #
480
- # filter_parameter_logging(:foo, "bar") { |k,v| v.reverse! if k =~ /secret/i }
481
- # => reverses the value to all keys matching /secret/i, and
482
- # replaces the value to all keys matching /foo|bar/i with "[FILTERED]"
483
- def filter_parameter_logging(*filter_words, &block)
484
- parameter_filter = Regexp.new(filter_words.collect{ |s| s.to_s }.join('|'), true) if filter_words.length > 0
485
-
486
- define_method(:filter_parameters) do |unfiltered_parameters|
487
- filtered_parameters = {}
488
-
489
- unfiltered_parameters.each do |key, value|
490
- if key =~ parameter_filter
491
- filtered_parameters[key] = '[FILTERED]'
492
- elsif value.is_a?(Hash)
493
- filtered_parameters[key] = filter_parameters(value)
494
- elsif value.is_a?(Array)
495
- filtered_parameters[key] = value.collect do |item|
496
- case item
497
- when Hash, Array
498
- filter_parameters(item)
499
- else
500
- item
501
- end
502
- end
503
- elsif block_given?
504
- key = key.dup
505
- value = value.dup if value.duplicable?
506
- yield key, value
507
- filtered_parameters[key] = value
508
- else
509
- filtered_parameters[key] = value
510
- end
511
- end
512
-
513
- filtered_parameters
514
- end
515
- protected :filter_parameters
516
- end
517
-
518
- delegate :exempt_from_layout, :to => 'ActionView::Template'
519
- end
520
-
521
- public
522
- # Extracts the action_name from the request parameters and performs that action.
523
- def process(request, response, method = :perform_action, *arguments) #:nodoc:
524
- response.request = request
525
-
526
- initialize_template_class(response)
527
- assign_shortcuts(request, response)
528
- initialize_current_url
529
- assign_names
530
-
531
- log_processing
532
- send(method, *arguments)
533
-
534
- send_response
535
- ensure
536
- process_cleanup
537
- end
538
-
539
- def send_response
540
- response.prepare!
541
- response
542
- end
543
-
544
- # Returns a URL that has been rewritten according to the options hash and the defined routes.
545
- # (For doing a complete redirect, use +redirect_to+).
546
- #
547
- # <tt>url_for</tt> is used to:
548
- #
549
- # All keys given to +url_for+ are forwarded to the Route module, save for the following:
550
- # * <tt>:anchor</tt> - Specifies the anchor name to be appended to the path. For example,
551
- # <tt>url_for :controller => 'posts', :action => 'show', :id => 10, :anchor => 'comments'</tt>
552
- # will produce "/posts/show/10#comments".
553
- # * <tt>:only_path</tt> - If true, returns the relative URL (omitting the protocol, host name, and port) (<tt>false</tt> by default).
554
- # * <tt>:trailing_slash</tt> - If true, adds a trailing slash, as in "/archive/2005/". Note that this
555
- # is currently not recommended since it breaks caching.
556
- # * <tt>:host</tt> - Overrides the default (current) host if provided.
557
- # * <tt>:protocol</tt> - Overrides the default (current) protocol if provided.
558
- # * <tt>:port</tt> - Optionally specify the port to connect to.
559
- # * <tt>:user</tt> - Inline HTTP authentication (only plucked out if <tt>:password</tt> is also present).
560
- # * <tt>:password</tt> - Inline HTTP authentication (only plucked out if <tt>:user</tt> is also present).
561
- # * <tt>:skip_relative_url_root</tt> - If true, the url is not constructed using the +relative_url_root+
562
- # of the request so the path will include the web server relative installation directory.
563
- #
564
- # The URL is generated from the remaining keys in the hash. A URL contains two key parts: the <base> and a query string.
565
- # Routes composes a query string as the key/value pairs not included in the <base>.
566
- #
567
- # The default Routes setup supports a typical Rails path of "controller/action/id" where action and id are optional, with
568
- # action defaulting to 'index' when not given. Here are some typical url_for statements and their corresponding URLs:
569
- #
570
- # url_for :controller => 'posts', :action => 'recent' # => 'proto://host.com/posts/recent'
571
- # url_for :controller => 'posts', :action => 'index' # => 'proto://host.com/posts'
572
- # url_for :controller => 'posts', :action => 'index', :port=>'8033' # => 'proto://host.com:8033/posts'
573
- # url_for :controller => 'posts', :action => 'show', :id => 10 # => 'proto://host.com/posts/show/10'
574
- # url_for :controller => 'posts', :user => 'd', :password => '123' # => 'proto://d:123@host.com/posts'
575
- #
576
- # When generating a new URL, missing values may be filled in from the current request's parameters. For example,
577
- # <tt>url_for :action => 'some_action'</tt> will retain the current controller, as expected. This behavior extends to
578
- # other parameters, including <tt>:controller</tt>, <tt>:id</tt>, and any other parameters that are placed into a Route's
579
- # path.
580
- #  
581
- # The URL helpers such as <tt>url_for</tt> have a limited form of memory: when generating a new URL, they can look for
582
- # missing values in the current request's parameters. Routes attempts to guess when a value should and should not be
583
- # taken from the defaults. There are a few simple rules on how this is performed:
584
- #
585
- # * If the controller name begins with a slash no defaults are used:
586
- #
587
- # url_for :controller => '/home'
588
- #
589
- # In particular, a leading slash ensures no namespace is assumed. Thus,
590
- # while <tt>url_for :controller => 'users'</tt> may resolve to
591
- # <tt>Admin::UsersController</tt> if the current controller lives under
592
- # that module, <tt>url_for :controller => '/users'</tt> ensures you link
593
- # to <tt>::UsersController</tt> no matter what.
594
- # * If the controller changes, the action will default to index unless provided
595
- #
596
- # The final rule is applied while the URL is being generated and is best illustrated by an example. Let us consider the
597
- # route given by <tt>map.connect 'people/:last/:first/:action', :action => 'bio', :controller => 'people'</tt>.
598
- #
599
- # Suppose that the current URL is "people/hh/david/contacts". Let's consider a few different cases of URLs which are generated
600
- # from this page.
601
- #
602
- # * <tt>url_for :action => 'bio'</tt> -- During the generation of this URL, default values will be used for the first and
603
- # last components, and the action shall change. The generated URL will be, "people/hh/david/bio".
604
- # * <tt>url_for :first => 'davids-little-brother'</tt> This generates the URL 'people/hh/davids-little-brother' -- note
605
- # that this URL leaves out the assumed action of 'bio'.
606
- #
607
- # However, you might ask why the action from the current request, 'contacts', isn't carried over into the new URL. The
608
- # answer has to do with the order in which the parameters appear in the generated path. In a nutshell, since the
609
- # value that appears in the slot for <tt>:first</tt> is not equal to default value for <tt>:first</tt> we stop using
610
- # defaults. On its own, this rule can account for much of the typical Rails URL behavior.
611
- #  
612
- # Although a convenience, defaults can occasionally get in your way. In some cases a default persists longer than desired.
613
- # The default may be cleared by adding <tt>:name => nil</tt> to <tt>url_for</tt>'s options.
614
- # This is often required when writing form helpers, since the defaults in play may vary greatly depending upon where the
615
- # helper is used from. The following line will redirect to PostController's default action, regardless of the page it is
616
- # displayed on:
617
- #
618
- # url_for :controller => 'posts', :action => nil
619
- def url_for(options = {})
620
- options ||= {}
621
- case options
622
- when String
623
- options
624
- when Hash
625
- @url.rewrite(rewrite_options(options))
626
- else
627
- polymorphic_url(options)
628
- end
629
- end
630
-
631
- # Converts the class name from something like "OneModule::TwoModule::NeatController" to "NeatController".
632
- def controller_class_name
633
- self.class.controller_class_name
634
- end
635
-
636
- # Converts the class name from something like "OneModule::TwoModule::NeatController" to "neat".
637
- def controller_name
638
- self.class.controller_name
639
- end
640
-
641
- # Converts the class name from something like "OneModule::TwoModule::NeatController" to "one_module/two_module/neat".
642
- def controller_path
643
- self.class.controller_path
644
- end
645
-
646
- def session_enabled?
647
- ActiveSupport::Deprecation.warn("Sessions are now lazy loaded. So if you don't access them, consider them disabled.", caller)
648
- end
649
-
650
- self.view_paths = []
651
-
652
- # View load paths for controller.
653
- def view_paths
654
- @template.view_paths
655
- end
656
-
657
- def view_paths=(value)
658
- @template.view_paths = ActionView::Base.process_view_paths(value)
659
- end
660
-
661
- # Adds a view_path to the front of the view_paths array.
662
- # This change affects the current request only.
663
- #
664
- # self.prepend_view_path("views/default")
665
- # self.prepend_view_path(["views/default", "views/custom"])
666
- #
667
- def prepend_view_path(path)
668
- @template.view_paths.unshift(*path)
669
- end
670
-
671
- # Adds a view_path to the end of the view_paths array.
672
- # This change affects the current request only.
673
- #
674
- # self.append_view_path("views/default")
675
- # self.append_view_path(["views/default", "views/custom"])
676
- #
677
- def append_view_path(path)
678
- @template.view_paths.push(*path)
679
- end
680
-
681
- protected
682
- # Renders the content that will be returned to the browser as the response body.
683
- #
684
- # === Rendering an action
685
- #
686
- # Action rendering is the most common form and the type used automatically by Action Controller when nothing else is
687
- # specified. By default, actions are rendered within the current layout (if one exists).
688
- #
689
- # # Renders the template for the action "goal" within the current controller
690
- # render :action => "goal"
691
- #
692
- # # Renders the template for the action "short_goal" within the current controller,
693
- # # but without the current active layout
694
- # render :action => "short_goal", :layout => false
695
- #
696
- # # Renders the template for the action "long_goal" within the current controller,
697
- # # but with a custom layout
698
- # render :action => "long_goal", :layout => "spectacular"
699
- #
700
- # === Rendering partials
701
- #
702
- # Partial rendering in a controller is most commonly used together with Ajax calls that only update one or a few elements on a page
703
- # without reloading. Rendering of partials from the controller makes it possible to use the same partial template in
704
- # both the full-page rendering (by calling it from within the template) and when sub-page updates happen (from the
705
- # controller action responding to Ajax calls). By default, the current layout is not used.
706
- #
707
- # # Renders the same partial with a local variable.
708
- # render :partial => "person", :locals => { :name => "david" }
709
- #
710
- # # Renders the partial, making @new_person available through
711
- # # the local variable 'person'
712
- # render :partial => "person", :object => @new_person
713
- #
714
- # # Renders a collection of the same partial by making each element
715
- # # of @winners available through the local variable "person" as it
716
- # # builds the complete response.
717
- # render :partial => "person", :collection => @winners
718
- #
719
- # # Renders a collection of partials but with a custom local variable name
720
- # render :partial => "admin_person", :collection => @winners, :as => :person
721
- #
722
- # # Renders the same collection of partials, but also renders the
723
- # # person_divider partial between each person partial.
724
- # render :partial => "person", :collection => @winners, :spacer_template => "person_divider"
725
- #
726
- # # Renders a collection of partials located in a view subfolder
727
- # # outside of our current controller. In this example we will be
728
- # # rendering app/views/shared/_note.r(html|xml) Inside the partial
729
- # # each element of @new_notes is available as the local var "note".
730
- # render :partial => "shared/note", :collection => @new_notes
731
- #
732
- # # Renders the partial with a status code of 500 (internal error).
733
- # render :partial => "broken", :status => 500
734
- #
735
- # Note that the partial filename must also be a valid Ruby variable name,
736
- # so e.g. 2005 and register-user are invalid.
737
- #
738
- #
739
- # == Automatic etagging
740
- #
741
- # Rendering will automatically insert the etag header on 200 OK responses. The etag is calculated using MD5 of the
742
- # response body. If a request comes in that has a matching etag, the response will be changed to a 304 Not Modified
743
- # and the response body will be set to an empty string. No etag header will be inserted if it's already set.
744
- #
745
- # === Rendering a template
746
- #
747
- # Template rendering works just like action rendering except that it takes a path relative to the template root.
748
- # The current layout is automatically applied.
749
- #
750
- # # Renders the template located in [TEMPLATE_ROOT]/weblog/show.r(html|xml) (in Rails, app/views/weblog/show.erb)
751
- # render :template => "weblog/show"
752
- #
753
- # # Renders the template with a local variable
754
- # render :template => "weblog/show", :locals => {:customer => Customer.new}
755
- #
756
- # === Rendering a file
757
- #
758
- # File rendering works just like action rendering except that it takes a filesystem path. By default, the path
759
- # is assumed to be absolute, and the current layout is not applied.
760
- #
761
- # # Renders the template located at the absolute filesystem path
762
- # render :file => "/path/to/some/template.erb"
763
- # render :file => "c:/path/to/some/template.erb"
764
- #
765
- # # Renders a template within the current layout, and with a 404 status code
766
- # render :file => "/path/to/some/template.erb", :layout => true, :status => 404
767
- # render :file => "c:/path/to/some/template.erb", :layout => true, :status => 404
768
- #
769
- # === Rendering text
770
- #
771
- # Rendering of text is usually used for tests or for rendering prepared content, such as a cache. By default, text
772
- # rendering is not done within the active layout.
773
- #
774
- # # Renders the clear text "hello world" with status code 200
775
- # render :text => "hello world!"
776
- #
777
- # # Renders the clear text "Explosion!" with status code 500
778
- # render :text => "Explosion!", :status => 500
779
- #
780
- # # Renders the clear text "Hi there!" within the current active layout (if one exists)
781
- # render :text => "Hi there!", :layout => true
782
- #
783
- # # Renders the clear text "Hi there!" within the layout
784
- # # placed in "app/views/layouts/special.r(html|xml)"
785
- # render :text => "Hi there!", :layout => "special"
786
- #
787
- # === Streaming data and/or controlling the page generation
788
- #
789
- # The <tt>:text</tt> option can also accept a Proc object, which can be used to:
790
- #
791
- # 1. stream on-the-fly generated data to the browser. Note that you should
792
- # use the methods provided by ActionController::Steaming instead if you
793
- # want to stream a buffer or a file.
794
- # 2. manually control the page generation. This should generally be avoided,
795
- # as it violates the separation between code and content, and because almost
796
- # everything that can be done with this method can also be done more cleanly
797
- # using one of the other rendering methods, most notably templates.
798
- #
799
- # Two arguments are passed to the proc, a <tt>response</tt> object and an
800
- # <tt>output</tt> object. The response object is equivalent to the return
801
- # value of the ActionController::Base#response method, and can be used to
802
- # control various things in the HTTP response, such as setting the
803
- # Content-Type header. The output object is an writable <tt>IO</tt>-like
804
- # object, so one can call <tt>write</tt> and <tt>flush</tt> on it.
805
- #
806
- # The following example demonstrates how one can stream a large amount of
807
- # on-the-fly generated data to the browser:
808
- #
809
- # # Streams about 180 MB of generated data to the browser.
810
- # render :text => proc { |response, output|
811
- # 10_000_000.times do |i|
812
- # output.write("This is line #{i}\n")
813
- # end
814
- # }
815
- #
816
- # Another example:
817
- #
818
- # # Renders "Hello from code!"
819
- # render :text => proc { |response, output| output.write("Hello from code!") }
820
- #
821
- # === Rendering XML
822
- #
823
- # Rendering XML sets the content type to application/xml.
824
- #
825
- # # Renders '<name>David</name>'
826
- # render :xml => {:name => "David"}.to_xml
827
- #
828
- # It's not necessary to call <tt>to_xml</tt> on the object you want to render, since <tt>render</tt> will
829
- # automatically do that for you:
830
- #
831
- # # Also renders '<name>David</name>'
832
- # render :xml => {:name => "David"}
833
- #
834
- # === Rendering JSON
835
- #
836
- # Rendering JSON sets the content type to application/json and optionally wraps the JSON in a callback. It is expected
837
- # that the response will be parsed (or eval'd) for use as a data structure.
838
- #
839
- # # Renders '{"name": "David"}'
840
- # render :json => {:name => "David"}.to_json
841
- #
842
- # It's not necessary to call <tt>to_json</tt> on the object you want to render, since <tt>render</tt> will
843
- # automatically do that for you:
844
- #
845
- # # Also renders '{"name": "David"}'
846
- # render :json => {:name => "David"}
847
- #
848
- # Sometimes the result isn't handled directly by a script (such as when the request comes from a SCRIPT tag),
849
- # so the <tt>:callback</tt> option is provided for these cases.
850
- #
851
- # # Renders 'show({"name": "David"})'
852
- # render :json => {:name => "David"}.to_json, :callback => 'show'
853
- #
854
- # === Rendering an inline template
855
- #
856
- # Rendering of an inline template works as a cross between text and action rendering where the source for the template
857
- # is supplied inline, like text, but its interpreted with ERb or Builder, like action. By default, ERb is used for rendering
858
- # and the current layout is not used.
859
- #
860
- # # Renders "hello, hello, hello, again"
861
- # render :inline => "<%= 'hello, ' * 3 + 'again' %>"
862
- #
863
- # # Renders "<p>Good seeing you!</p>" using Builder
864
- # render :inline => "xml.p { 'Good seeing you!' }", :type => :builder
865
- #
866
- # # Renders "hello david"
867
- # render :inline => "<%= 'hello ' + name %>", :locals => { :name => "david" }
868
- #
869
- # === Rendering inline JavaScriptGenerator page updates
870
- #
871
- # In addition to rendering JavaScriptGenerator page updates with Ajax in RJS templates (see ActionView::Base for details),
872
- # you can also pass the <tt>:update</tt> parameter to +render+, along with a block, to render page updates inline.
873
- #
874
- # render :update do |page|
875
- # page.replace_html 'user_list', :partial => 'user', :collection => @users
876
- # page.visual_effect :highlight, 'user_list'
877
- # end
878
- #
879
- # === Rendering vanilla JavaScript
880
- #
881
- # In addition to using RJS with render :update, you can also just render vanilla JavaScript with :js.
882
- #
883
- # # Renders "alert('hello')" and sets the mime type to text/javascript
884
- # render :js => "alert('hello')"
885
- #
886
- # === Rendering with status and location headers
887
- # All renders take the <tt>:status</tt> and <tt>:location</tt> options and turn them into headers. They can even be used together:
888
- #
889
- # render :xml => post.to_xml, :status => :created, :location => post_url(post)
890
- def render(options = nil, extra_options = {}, &block) #:doc:
891
- raise DoubleRenderError, "Can only render or redirect once per action" if performed?
892
-
893
- validate_render_arguments(options, extra_options, block_given?)
894
-
895
- if options.nil?
896
- options = { :template => default_template, :layout => true }
897
- elsif options == :update
898
- options = extra_options.merge({ :update => true })
899
- elsif options.is_a?(String) || options.is_a?(Symbol)
900
- case options.to_s.index('/')
901
- when 0
902
- extra_options[:file] = options
903
- when nil
904
- extra_options[:action] = options
905
- else
906
- extra_options[:template] = options
907
- end
908
-
909
- options = extra_options
910
- elsif !options.is_a?(Hash)
911
- extra_options[:partial] = options
912
- options = extra_options
913
- end
914
-
915
- layout = pick_layout(options)
916
- response.layout = layout.path_without_format_and_extension if layout
917
- logger.info("Rendering template within #{layout.path_without_format_and_extension}") if logger && layout
918
-
919
- if content_type = options[:content_type]
920
- response.content_type = content_type.to_s
921
- end
922
-
923
- if location = options[:location]
924
- response.headers["Location"] = url_for(location)
925
- end
926
-
927
- if options.has_key?(:text)
928
- text = layout ? @template.render(options.merge(:text => options[:text], :layout => layout)) : options[:text]
929
- render_for_text(text, options[:status])
930
-
931
- else
932
- if file = options[:file]
933
- render_for_file(file, options[:status], layout, options[:locals] || {})
934
-
935
- elsif template = options[:template]
936
- render_for_file(template, options[:status], layout, options[:locals] || {})
937
-
938
- elsif inline = options[:inline]
939
- render_for_text(@template.render(options.merge(:layout => layout)), options[:status])
940
-
941
- elsif action_name = options[:action]
942
- render_for_file(default_template(action_name.to_s), options[:status], layout)
943
-
944
- elsif xml = options[:xml]
945
- response.content_type ||= Mime::XML
946
- render_for_text(xml.respond_to?(:to_xml) ? xml.to_xml : xml, options[:status])
947
-
948
- elsif js = options[:js]
949
- response.content_type ||= Mime::JS
950
- render_for_text(js, options[:status])
951
-
952
- elsif options.include?(:json)
953
- json = options[:json]
954
- json = ActiveSupport::JSON.encode(json) unless json.is_a?(String)
955
- json = "#{options[:callback]}(#{json})" unless options[:callback].blank?
956
- response.content_type ||= Mime::JSON
957
- render_for_text(json, options[:status])
958
-
959
- elsif options[:partial]
960
- options[:partial] = default_template_name if options[:partial] == true
961
- if layout
962
- render_for_text(@template.render(:text => @template.render(options), :layout => layout), options[:status])
963
- else
964
- render_for_text(@template.render(options), options[:status])
965
- end
966
-
967
- elsif options[:update]
968
- @template.send(:_evaluate_assigns_and_ivars)
969
-
970
- generator = ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.new(@template, &block)
971
- response.content_type = Mime::JS
972
- render_for_text(generator.to_s, options[:status])
973
-
974
- elsif options[:nothing]
975
- render_for_text(nil, options[:status])
976
-
977
- else
978
- render_for_file(default_template, options[:status], layout)
979
- end
980
- end
981
- end
982
-
983
- # Renders according to the same rules as <tt>render</tt>, but returns the result in a string instead
984
- # of sending it as the response body to the browser.
985
- def render_to_string(options = nil, &block) #:doc:
986
- render(options, &block)
987
- ensure
988
- response.content_type = nil
989
- erase_render_results
990
- reset_variables_added_to_assigns
991
- end
992
-
993
- # Return a response that has no content (merely headers). The options
994
- # argument is interpreted to be a hash of header names and values.
995
- # This allows you to easily return a response that consists only of
996
- # significant headers:
997
- #
998
- # head :created, :location => person_path(@person)
999
- #
1000
- # It can also be used to return exceptional conditions:
1001
- #
1002
- # return head(:method_not_allowed) unless request.post?
1003
- # return head(:bad_request) unless valid_request?
1004
- # render
1005
- def head(*args)
1006
- if args.length > 2
1007
- raise ArgumentError, "too many arguments to head"
1008
- elsif args.empty?
1009
- raise ArgumentError, "too few arguments to head"
1010
- end
1011
- options = args.extract_options!
1012
- status = interpret_status(args.shift || options.delete(:status) || :ok)
1013
-
1014
- options.each do |key, value|
1015
- headers[key.to_s.dasherize.split(/-/).map { |v| v.capitalize }.join("-")] = value.to_s
1016
- end
1017
-
1018
- render :nothing => true, :status => status
1019
- end
1020
-
1021
- # Clears the rendered results, allowing for another render to be performed.
1022
- def erase_render_results #:nodoc:
1023
- response.body = nil
1024
- @performed_render = false
1025
- end
1026
-
1027
- # Clears the redirected results from the headers, resets the status to 200 and returns
1028
- # the URL that was used to redirect or nil if there was no redirected URL
1029
- # Note that +redirect_to+ will change the body of the response to indicate a redirection.
1030
- # The response body is not reset here, see +erase_render_results+
1031
- def erase_redirect_results #:nodoc:
1032
- @performed_redirect = false
1033
- response.redirected_to = nil
1034
- response.redirected_to_method_params = nil
1035
- response.status = DEFAULT_RENDER_STATUS_CODE
1036
- response.headers.delete('Location')
1037
- end
1038
-
1039
- # Erase both render and redirect results
1040
- def erase_results #:nodoc:
1041
- erase_render_results
1042
- erase_redirect_results
1043
- end
1044
-
1045
- def rewrite_options(options) #:nodoc:
1046
- if defaults = default_url_options(options)
1047
- defaults.merge(options)
1048
- else
1049
- options
1050
- end
1051
- end
1052
-
1053
- # Overwrite to implement a number of default options that all url_for-based methods will use. The default options should come in
1054
- # the form of a hash, just like the one you would use for url_for directly. Example:
1055
- #
1056
- # def default_url_options(options)
1057
- # { :project => @project.active? ? @project.url_name : "unknown" }
1058
- # end
1059
- #
1060
- # As you can infer from the example, this is mostly useful for situations where you want to centralize dynamic decisions about the
1061
- # urls as they stem from the business domain. Please note that any individual url_for call can always override the defaults set
1062
- # by this method.
1063
- def default_url_options(options = nil)
1064
- end
1065
-
1066
- # Redirects the browser to the target specified in +options+. This parameter can take one of three forms:
1067
- #
1068
- # * <tt>Hash</tt> - The URL will be generated by calling url_for with the +options+.
1069
- # * <tt>Record</tt> - The URL will be generated by calling url_for with the +options+, which will reference a named URL for that record.
1070
- # * <tt>String</tt> starting with <tt>protocol://</tt> (like <tt>http://</tt>) - Is passed straight through as the target for redirection.
1071
- # * <tt>String</tt> not containing a protocol - The current protocol and host is prepended to the string.
1072
- # * <tt>:back</tt> - Back to the page that issued the request. Useful for forms that are triggered from multiple places.
1073
- # Short-hand for <tt>redirect_to(request.env["HTTP_REFERER"])</tt>
1074
- #
1075
- # Examples:
1076
- # redirect_to :action => "show", :id => 5
1077
- # redirect_to post
1078
- # redirect_to "http://www.rubyonrails.org"
1079
- # redirect_to "/images/screenshot.jpg"
1080
- # redirect_to articles_url
1081
- # redirect_to :back
1082
- #
1083
- # The redirection happens as a "302 Moved" header unless otherwise specified.
1084
- #
1085
- # Examples:
1086
- # redirect_to post_url(@post), :status => :found
1087
- # redirect_to :action=>'atom', :status => :moved_permanently
1088
- # redirect_to post_url(@post), :status => 301
1089
- # redirect_to :action=>'atom', :status => 302
1090
- #
1091
- # The status code can either be a standard {HTTP Status code}[http://www.iana.org/assignments/http-status-codes] as an
1092
- # integer, or a symbol representing the downcased, underscored and symbolized description.
1093
- #
1094
- # It is also possible to assign a flash message as part of the redirection. There are two special accessors for commonly used the flash names
1095
- # +alert+ and +notice+ as well as a general purpose +flash+ bucket.
1096
- #
1097
- # Examples:
1098
- # redirect_to post_url(@post), :alert => "Watch it, mister!"
1099
- # redirect_to post_url(@post), :status=> :found, :notice => "Pay attention to the road"
1100
- # redirect_to post_url(@post), :status => 301, :flash => { :updated_post_id => @post.id }
1101
- # redirect_to { :action=>'atom' }, :alert => "Something serious happened"
1102
- #
1103
- # When using <tt>redirect_to :back</tt>, if there is no referrer, RedirectBackError will be raised. You may specify some fallback
1104
- # behavior for this case by rescuing RedirectBackError.
1105
- def redirect_to(options = {}, response_status = {}) #:doc:
1106
- raise ActionControllerError.new("Cannot redirect to nil!") if options.nil?
1107
-
1108
- if options.is_a?(Hash) && options[:status]
1109
- status = options.delete(:status)
1110
- elsif response_status[:status]
1111
- status = response_status[:status]
1112
- else
1113
- status = 302
1114
- end
1115
-
1116
- response.redirected_to = options
1117
-
1118
- case options
1119
- # The scheme name consist of a letter followed by any combination of
1120
- # letters, digits, and the plus ("+"), period ("."), or hyphen ("-")
1121
- # characters; and is terminated by a colon (":").
1122
- when %r{^\w[\w\d+.-]*:.*}
1123
- redirect_to_full_url(options, status)
1124
- when String
1125
- redirect_to_full_url(request.protocol + request.host_with_port + options, status)
1126
- when :back
1127
- if referer = request.headers["Referer"]
1128
- redirect_to(referer, :status=>status)
1129
- else
1130
- raise RedirectBackError
1131
- end
1132
- else
1133
- redirect_to_full_url(url_for(options), status)
1134
- end
1135
- end
1136
-
1137
- def redirect_to_full_url(url, status)
1138
- raise DoubleRenderError if performed?
1139
- logger.info("Redirected to #{url}") if logger && logger.info?
1140
- response.redirect(url, interpret_status(status))
1141
- @performed_redirect = true
1142
- end
1143
-
1144
- # Sets the etag and/or last_modified on the response and checks it against
1145
- # the client request. If the request doesn't match the options provided, the
1146
- # request is considered stale and should be generated from scratch. Otherwise,
1147
- # it's fresh and we don't need to generate anything and a reply of "304 Not Modified" is sent.
1148
- #
1149
- # Parameters:
1150
- # * <tt>:etag</tt>
1151
- # * <tt>:last_modified</tt>
1152
- # * <tt>:public</tt> By default the Cache-Control header is private, set this to true if you want your application to be cachable by other devices (proxy caches).
1153
- #
1154
- # Example:
1155
- #
1156
- # def show
1157
- # @article = Article.find(params[:id])
1158
- #
1159
- # if stale?(:etag => @article, :last_modified => @article.created_at.utc)
1160
- # @statistics = @article.really_expensive_call
1161
- # respond_to do |format|
1162
- # # all the supported formats
1163
- # end
1164
- # end
1165
- # end
1166
- def stale?(options)
1167
- fresh_when(options)
1168
- !request.fresh?(response)
1169
- end
1170
-
1171
- # Sets the etag, last_modified, or both on the response and renders a
1172
- # "304 Not Modified" response if the request is already fresh.
1173
- #
1174
- # Parameters:
1175
- # * <tt>:etag</tt>
1176
- # * <tt>:last_modified</tt>
1177
- # * <tt>:public</tt> By default the Cache-Control header is private, set this to true if you want your application to be cachable by other devices (proxy caches).
1178
- #
1179
- # Example:
1180
- #
1181
- # def show
1182
- # @article = Article.find(params[:id])
1183
- # fresh_when(:etag => @article, :last_modified => @article.created_at.utc, :public => true)
1184
- # end
1185
- #
1186
- # This will render the show template if the request isn't sending a matching etag or
1187
- # If-Modified-Since header and just a "304 Not Modified" response if there's a match.
1188
- #
1189
- def fresh_when(options)
1190
- options.assert_valid_keys(:etag, :last_modified, :public)
1191
-
1192
- response.etag = options[:etag] if options[:etag]
1193
- response.last_modified = options[:last_modified] if options[:last_modified]
1194
-
1195
- if options[:public]
1196
- cache_control = response.headers["Cache-Control"].split(",").map {|k| k.strip }
1197
- cache_control.delete("private")
1198
- cache_control.delete("no-cache")
1199
- cache_control << "public"
1200
- response.headers["Cache-Control"] = cache_control.join(', ')
1201
- end
1202
-
1203
- if request.fresh?(response)
1204
- head :not_modified
1205
- end
1206
- end
1207
-
1208
- # Sets a HTTP 1.1 Cache-Control header. Defaults to issuing a "private" instruction, so that
1209
- # intermediate caches shouldn't cache the response.
1210
- #
1211
- # Examples:
1212
- # expires_in 20.minutes
1213
- # expires_in 3.hours, :public => true
1214
- # expires in 3.hours, 'max-stale' => 5.hours, :public => true
1215
- #
1216
- # This method will overwrite an existing Cache-Control header.
1217
- # See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html for more possibilities.
1218
- def expires_in(seconds, options = {}) #:doc:
1219
- cache_control = response.headers["Cache-Control"].split(",").map {|k| k.strip }
1220
-
1221
- cache_control << "max-age=#{seconds}"
1222
- cache_control.delete("no-cache")
1223
- if options[:public]
1224
- cache_control.delete("private")
1225
- cache_control << "public"
1226
- else
1227
- cache_control << "private"
1228
- end
1229
-
1230
- # This allows for additional headers to be passed through like 'max-stale' => 5.hours
1231
- cache_control += options.symbolize_keys.reject{|k,v| k == :public || k == :private }.map{ |k,v| v == true ? k.to_s : "#{k.to_s}=#{v.to_s}"}
1232
-
1233
- response.headers["Cache-Control"] = cache_control.join(', ')
1234
- end
1235
-
1236
- # Sets a HTTP 1.1 Cache-Control header of "no-cache" so no caching should occur by the browser or
1237
- # intermediate caches (like caching proxy servers).
1238
- def expires_now #:doc:
1239
- response.headers["Cache-Control"] = "no-cache"
1240
- end
1241
-
1242
- # Resets the session by clearing out all the objects stored within and initializing a new session object.
1243
- def reset_session #:doc:
1244
- request.reset_session
1245
- @_session = request.session
1246
- end
1247
-
1248
- private
1249
- def render_for_file(template_path, status = nil, layout = nil, locals = {}) #:nodoc:
1250
- path = template_path.respond_to?(:path_without_format_and_extension) ? template_path.path_without_format_and_extension : template_path
1251
- logger.info("Rendering #{path}" + (status ? " (#{status})" : '')) if logger
1252
- render_for_text @template.render(:file => template_path, :locals => locals, :layout => layout), status
1253
- end
1254
-
1255
- def render_for_text(text = nil, status = nil, append_response = false) #:nodoc:
1256
- @performed_render = true
1257
-
1258
- response.status = interpret_status(status || DEFAULT_RENDER_STATUS_CODE)
1259
-
1260
- if append_response
1261
- response.body ||= ''
1262
- response.body << text.to_s
1263
- else
1264
- response.body = case text
1265
- when Proc then text
1266
- when nil then " " # Safari doesn't pass the headers of the return if the response is zero length
1267
- else text.to_s
1268
- end
1269
- end
1270
- end
1271
-
1272
- def validate_render_arguments(options, extra_options, has_block)
1273
- if options && (has_block && options != :update) && !options.is_a?(String) && !options.is_a?(Hash) && !options.is_a?(Symbol)
1274
- raise RenderError, "You called render with invalid options : #{options.inspect}"
1275
- end
1276
-
1277
- if !extra_options.is_a?(Hash)
1278
- raise RenderError, "You called render with invalid options : #{options.inspect}, #{extra_options.inspect}"
1279
- end
1280
- end
1281
-
1282
- def initialize_template_class(response)
1283
- response.template = ActionView::Base.new(self.class.view_paths, {}, self)
1284
- response.template.helpers.send :include, self.class.master_helper_module
1285
- response.redirected_to = nil
1286
- @performed_render = @performed_redirect = false
1287
- end
1288
-
1289
- def assign_shortcuts(request, response)
1290
- @_request, @_params = request, request.parameters
1291
-
1292
- @_response = response
1293
- @_response.session = request.session
1294
-
1295
- @_session = @_response.session
1296
- @template = @_response.template
1297
-
1298
- @_headers = @_response.headers
1299
- end
1300
-
1301
- def initialize_current_url
1302
- @url = UrlRewriter.new(request, params.clone)
1303
- end
1304
-
1305
- def log_processing
1306
- if logger && logger.info?
1307
- log_processing_for_request_id
1308
- log_processing_for_parameters
1309
- end
1310
- end
1311
-
1312
- def log_processing_for_request_id
1313
- request_id = "\n\nProcessing #{self.class.name}\##{action_name} "
1314
- request_id << "to #{params[:format]} " if params[:format]
1315
- request_id << "(for #{request_origin}) [#{request.method.to_s.upcase}]"
1316
-
1317
- logger.info(request_id)
1318
- end
1319
-
1320
- def log_processing_for_parameters
1321
- parameters = respond_to?(:filter_parameters) ? filter_parameters(params) : params.dup
1322
- parameters = parameters.except!(:controller, :action, :format, :_method)
1323
-
1324
- logger.info " Parameters: #{parameters.inspect}" unless parameters.empty?
1325
- end
1326
-
1327
- def default_render #:nodoc:
1
+ module ActionController
2
+ class Base < Metal
3
+ abstract!
4
+
5
+ include AbstractController::Callbacks
6
+ include AbstractController::Layouts
7
+ include AbstractController::Translation
8
+
9
+ include ActionController::Helpers
10
+
11
+ include ActionController::HideActions
12
+ include ActionController::UrlFor
13
+ include ActionController::Redirecting
14
+ include ActionController::Rendering
15
+ include ActionController::Renderers::All
16
+ include ActionController::ConditionalGet
17
+ include ActionController::RackDelegation
18
+ include ActionController::Configuration
19
+
20
+ # Legacy modules
21
+ include SessionManagement
22
+ include ActionController::Caching
23
+ include ActionController::MimeResponds
24
+
25
+ # Rails 2.x compatibility
26
+ include ActionController::Compatibility
27
+
28
+ include ActionController::Cookies
29
+ include ActionController::Flash
30
+ include ActionController::Verification
31
+ include ActionController::RequestForgeryProtection
32
+ include ActionController::Streaming
33
+ include ActionController::HttpAuthentication::Basic::ControllerMethods
34
+ include ActionController::HttpAuthentication::Digest::ControllerMethods
35
+
36
+ # Add instrumentations hooks at the bottom, to ensure they instrument
37
+ # all the methods properly.
38
+ include ActionController::Instrumentation
39
+
40
+ # TODO: Extract into its own module
41
+ # This should be moved together with other normalizing behavior
42
+ module ImplicitRender
43
+ def send_action(*)
44
+ ret = super
45
+ default_render unless response_body
46
+ ret
47
+ end
48
+
49
+ def default_render
1328
50
  render
1329
51
  end
1330
52
 
1331
- def perform_action
1332
- if action_methods.include?(action_name)
1333
- send(action_name)
1334
- default_render unless performed?
1335
- elsif respond_to? :method_missing
1336
- method_missing action_name
1337
- default_render unless performed?
1338
- else
1339
- begin
1340
- default_render
1341
- rescue ActionView::MissingTemplate => e
1342
- # Was the implicit template missing, or was it another template?
1343
- if e.path == default_template_name
1344
- raise UnknownAction, "No action responded to #{action_name}. Actions: #{action_methods.sort.to_sentence(:locale => :en)}", caller
1345
- else
1346
- raise e
1347
- end
53
+ def method_for_action(action_name)
54
+ super || begin
55
+ if template_exists?(action_name.to_s, {:formats => formats}, :_prefix => controller_path)
56
+ "default_render"
1348
57
  end
1349
58
  end
1350
59
  end
60
+ end
1351
61
 
1352
- def performed?
1353
- @performed_render || @performed_redirect
1354
- end
1355
-
1356
- def assign_names
1357
- @action_name = (params['action'] || 'index')
1358
- end
1359
-
1360
- def action_methods
1361
- self.class.action_methods
1362
- end
1363
-
1364
- def self.action_methods
1365
- @action_methods ||=
1366
- # All public instance methods of this class, including ancestors
1367
- public_instance_methods(true).map { |m| m.to_s }.to_set -
1368
- # Except for public instance methods of Base and its ancestors
1369
- Base.public_instance_methods(true).map { |m| m.to_s } +
1370
- # Be sure to include shadowed public instance methods of this class
1371
- public_instance_methods(false).map { |m| m.to_s } -
1372
- # And always exclude explicitly hidden actions
1373
- hidden_actions
1374
- end
1375
-
1376
- def reset_variables_added_to_assigns
1377
- @template.instance_variable_set("@assigns_added", nil)
1378
- end
1379
-
1380
- def request_origin
1381
- # this *needs* to be cached!
1382
- # otherwise you'd get different results if calling it more than once
1383
- @request_origin ||= "#{request.remote_ip} at #{Time.now.to_s(:db)}"
1384
- end
1385
-
1386
- def complete_request_uri
1387
- "#{request.protocol}#{request.host}#{request.request_uri}"
1388
- end
62
+ include ImplicitRender
1389
63
 
1390
- def default_template(action_name = self.action_name)
1391
- self.view_paths.find_template(default_template_name(action_name), default_template_format)
1392
- end
64
+ include ActionController::Rescue
1393
65
 
1394
- def default_template_name(action_name = self.action_name)
1395
- if action_name
1396
- action_name = action_name.to_s
1397
- if action_name.include?('/') && template_path_includes_controller?(action_name)
1398
- action_name = strip_out_controller(action_name)
1399
- end
1400
- end
1401
- "#{self.controller_path}/#{action_name}"
1402
- end
66
+ def self.inherited(klass)
67
+ ::ActionController::Base.subclasses << klass.to_s
68
+ super
69
+ klass.helper :all
70
+ end
1403
71
 
1404
- def strip_out_controller(path)
1405
- path.split('/', 2).last
1406
- end
72
+ def self.subclasses
73
+ @subclasses ||= []
74
+ end
1407
75
 
1408
- def template_path_includes_controller?(path)
1409
- self.controller_path.split('/')[-1] == path.split('/')[0]
1410
- end
76
+ # This method has been moved to ActionDispatch::Request.filter_parameters
77
+ def self.filter_parameter_logging(*args, &block)
78
+ ActiveSupport::Deprecation.warn("Setting filter_parameter_logging in ActionController is deprecated and has no longer effect, please set 'config.filter_parameters' in config/application.rb instead", caller)
79
+ filter = Rails.application.config.filter_parameters
80
+ filter.concat(args)
81
+ filter << block if block
82
+ filter
83
+ end
1411
84
 
1412
- def process_cleanup
1413
- end
1414
- end
85
+ protected
1415
86
 
1416
- Base.class_eval do
1417
- [ Filters, Layout, Benchmarking, Rescue, MimeResponds, Helpers, Flash,
1418
- Cookies, Caching, Verification, Streaming, SessionManagement,
1419
- HttpAuthentication::Basic::ControllerMethods, HttpAuthentication::Digest::ControllerMethods,
1420
- RecordIdentifier, RequestForgeryProtection, Translation
1421
- ].each do |mod|
1422
- include mod
87
+ # Overwrite url rewriter to use request.
88
+ def _url_rewriter
89
+ return ActionController::UrlRewriter unless request
90
+ @_url_rewriter ||= ActionController::UrlRewriter.new(request, params)
1423
91
  end
1424
92
  end
1425
93
  end