actionpack 3.0.20 → 3.1.0.beta1

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 (161) hide show
  1. data/CHANGELOG +88 -142
  2. data/MIT-LICENSE +1 -1
  3. data/README.rdoc +5 -6
  4. data/lib/abstract_controller.rb +1 -0
  5. data/lib/abstract_controller/asset_paths.rb +2 -2
  6. data/lib/abstract_controller/base.rb +24 -19
  7. data/lib/abstract_controller/callbacks.rb +19 -19
  8. data/lib/abstract_controller/helpers.rb +11 -13
  9. data/lib/abstract_controller/layouts.rb +4 -5
  10. data/lib/abstract_controller/railties/routes_helpers.rb +18 -0
  11. data/lib/abstract_controller/rendering.rb +34 -31
  12. data/lib/abstract_controller/url_for.rb +27 -0
  13. data/lib/abstract_controller/view_paths.rb +31 -6
  14. data/lib/action_controller.rb +5 -3
  15. data/lib/action_controller/base.rb +15 -16
  16. data/lib/action_controller/caching.rb +2 -2
  17. data/lib/action_controller/caching/actions.rb +11 -12
  18. data/lib/action_controller/caching/fragments.rb +41 -19
  19. data/lib/action_controller/caching/pages.rb +3 -9
  20. data/lib/action_controller/caching/sweeping.rb +0 -1
  21. data/lib/action_controller/deprecated.rb +1 -1
  22. data/lib/action_controller/log_subscriber.rb +1 -1
  23. data/lib/action_controller/metal.rb +78 -20
  24. data/lib/action_controller/metal/compatibility.rb +0 -9
  25. data/lib/action_controller/metal/conditional_get.rb +9 -9
  26. data/lib/action_controller/metal/data_streaming.rb +145 -0
  27. data/lib/action_controller/metal/force_ssl.rb +35 -0
  28. data/lib/action_controller/metal/head.rb +1 -1
  29. data/lib/action_controller/metal/helpers.rb +37 -44
  30. data/lib/action_controller/metal/hide_actions.rb +2 -3
  31. data/lib/action_controller/metal/http_authentication.rb +41 -38
  32. data/lib/action_controller/metal/implicit_render.rb +13 -13
  33. data/lib/action_controller/metal/instrumentation.rb +2 -2
  34. data/lib/action_controller/metal/mime_responds.rb +25 -19
  35. data/lib/action_controller/metal/params_wrapper.rb +224 -0
  36. data/lib/action_controller/metal/redirecting.rb +6 -2
  37. data/lib/action_controller/metal/renderers.rb +50 -36
  38. data/lib/action_controller/metal/rendering.rb +34 -25
  39. data/lib/action_controller/metal/request_forgery_protection.rb +18 -36
  40. data/lib/action_controller/metal/responder.rb +47 -12
  41. data/lib/action_controller/metal/streaming.rb +244 -138
  42. data/lib/action_controller/metal/testing.rb +0 -9
  43. data/lib/action_controller/metal/url_for.rb +12 -14
  44. data/lib/action_controller/railtie.rb +19 -37
  45. data/lib/action_controller/railties/paths.rb +24 -0
  46. data/lib/action_controller/record_identifier.rb +4 -10
  47. data/lib/action_controller/test_case.rb +36 -19
  48. data/lib/action_controller/vendor/html-scanner/html/node.rb +5 -5
  49. data/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +3 -3
  50. data/lib/action_controller/vendor/html-scanner/html/selector.rb +2 -0
  51. data/lib/action_dispatch.rb +4 -1
  52. data/lib/action_dispatch/http/cache.rb +5 -32
  53. data/lib/action_dispatch/http/filter_parameters.rb +3 -1
  54. data/lib/action_dispatch/http/mime_negotiation.rb +22 -3
  55. data/lib/action_dispatch/http/mime_type.rb +45 -5
  56. data/lib/action_dispatch/http/rack_cache.rb +58 -0
  57. data/lib/action_dispatch/http/request.rb +27 -41
  58. data/lib/action_dispatch/http/response.rb +56 -54
  59. data/lib/action_dispatch/http/upload.rb +1 -11
  60. data/lib/action_dispatch/http/url.rb +102 -42
  61. data/lib/action_dispatch/middleware/callbacks.rb +8 -25
  62. data/lib/action_dispatch/middleware/closed_error.rb +7 -0
  63. data/lib/action_dispatch/middleware/cookies.rb +37 -15
  64. data/lib/action_dispatch/middleware/flash.rb +80 -11
  65. data/lib/action_dispatch/middleware/params_parser.rb +2 -2
  66. data/lib/action_dispatch/middleware/reloader.rb +76 -0
  67. data/lib/action_dispatch/middleware/session/abstract_store.rb +56 -226
  68. data/lib/action_dispatch/middleware/session/cookie_store.rb +20 -44
  69. data/lib/action_dispatch/middleware/session/mem_cache_store.rb +7 -46
  70. data/lib/action_dispatch/middleware/show_exceptions.rb +15 -2
  71. data/lib/action_dispatch/middleware/stack.rb +50 -17
  72. data/lib/action_dispatch/middleware/static.rb +41 -29
  73. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb +3 -3
  74. data/lib/action_dispatch/middleware/templates/rescues/_trace.erb +3 -3
  75. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb +3 -3
  76. data/lib/action_dispatch/middleware/templates/rescues/layout.erb +4 -2
  77. data/lib/action_dispatch/middleware/templates/rescues/template_error.erb +2 -6
  78. data/lib/action_dispatch/railtie.rb +8 -0
  79. data/lib/action_dispatch/routing.rb +13 -1
  80. data/lib/action_dispatch/routing/mapper.rb +345 -227
  81. data/lib/action_dispatch/routing/polymorphic_routes.rb +33 -13
  82. data/lib/action_dispatch/routing/redirection.rb +110 -0
  83. data/lib/action_dispatch/routing/route.rb +15 -13
  84. data/lib/action_dispatch/routing/route_set.rb +116 -90
  85. data/lib/action_dispatch/routing/routes_proxy.rb +35 -0
  86. data/lib/action_dispatch/routing/url_for.rb +25 -1
  87. data/lib/action_dispatch/testing/assertions/response.rb +8 -10
  88. data/lib/action_dispatch/testing/assertions/routing.rb +15 -15
  89. data/lib/action_dispatch/testing/assertions/selector.rb +13 -220
  90. data/lib/action_dispatch/testing/integration.rb +37 -28
  91. data/lib/action_dispatch/testing/performance_test.rb +1 -3
  92. data/lib/action_dispatch/testing/test_process.rb +1 -1
  93. data/lib/action_dispatch/testing/test_request.rb +9 -3
  94. data/lib/action_dispatch/testing/test_response.rb +4 -111
  95. data/lib/action_pack.rb +1 -1
  96. data/lib/action_pack/version.rb +3 -3
  97. data/lib/action_view.rb +39 -24
  98. data/lib/action_view/base.rb +61 -86
  99. data/lib/action_view/buffers.rb +43 -0
  100. data/lib/action_view/context.rb +21 -24
  101. data/lib/action_view/flows.rb +79 -0
  102. data/lib/action_view/helpers.rb +8 -6
  103. data/lib/action_view/helpers/active_model_helper.rb +0 -23
  104. data/lib/action_view/helpers/asset_paths.rb +79 -0
  105. data/lib/action_view/helpers/asset_tag_helper.rb +30 -500
  106. data/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb +147 -0
  107. data/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb +101 -0
  108. data/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb +200 -0
  109. data/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb +152 -0
  110. data/lib/action_view/helpers/atom_feed_helper.rb +2 -2
  111. data/lib/action_view/helpers/cache_helper.rb +11 -19
  112. data/lib/action_view/helpers/capture_helper.rb +19 -8
  113. data/lib/action_view/helpers/controller_helper.rb +21 -0
  114. data/lib/action_view/helpers/csrf_helper.rb +22 -4
  115. data/lib/action_view/helpers/date_helper.rb +36 -22
  116. data/lib/action_view/helpers/form_helper.rb +199 -113
  117. data/lib/action_view/helpers/form_options_helper.rb +10 -11
  118. data/lib/action_view/helpers/form_tag_helper.rb +94 -22
  119. data/lib/action_view/helpers/javascript_helper.rb +24 -107
  120. data/lib/action_view/helpers/number_helper.rb +36 -33
  121. data/lib/action_view/helpers/output_safety_helper.rb +38 -0
  122. data/lib/action_view/helpers/record_tag_helper.rb +6 -6
  123. data/lib/action_view/helpers/rendering_helper.rb +90 -0
  124. data/lib/action_view/helpers/sanitize_helper.rb +2 -2
  125. data/lib/action_view/helpers/sprockets_helper.rb +69 -0
  126. data/lib/action_view/helpers/tag_helper.rb +34 -12
  127. data/lib/action_view/helpers/text_helper.rb +30 -145
  128. data/lib/action_view/helpers/translation_helper.rb +10 -17
  129. data/lib/action_view/helpers/url_helper.rb +70 -67
  130. data/lib/action_view/locale/en.yml +1 -1
  131. data/lib/action_view/lookup_context.rb +36 -14
  132. data/lib/action_view/{paths.rb → path_set.rb} +9 -8
  133. data/lib/action_view/railtie.rb +12 -4
  134. data/lib/action_view/renderer/abstract_renderer.rb +36 -0
  135. data/lib/action_view/{render/partials.rb → renderer/partial_renderer.rb} +147 -146
  136. data/lib/action_view/renderer/renderer.rb +54 -0
  137. data/lib/action_view/renderer/streaming_template_renderer.rb +106 -0
  138. data/lib/action_view/renderer/template_renderer.rb +74 -0
  139. data/lib/action_view/template.rb +91 -54
  140. data/lib/action_view/template/error.rb +11 -8
  141. data/lib/action_view/template/handler.rb +9 -1
  142. data/lib/action_view/template/handlers.rb +9 -9
  143. data/lib/action_view/template/handlers/builder.rb +4 -4
  144. data/lib/action_view/template/handlers/erb.rb +21 -41
  145. data/lib/action_view/template/resolver.rb +171 -57
  146. data/lib/action_view/template/text.rb +0 -4
  147. data/lib/action_view/test_case.rb +32 -16
  148. data/lib/action_view/testing/resolvers.rb +16 -10
  149. data/lib/sprockets/railtie.rb +100 -0
  150. metadata +162 -140
  151. checksums.yaml +0 -7
  152. data/lib/action_controller/deprecated/base.rb +0 -143
  153. data/lib/action_controller/deprecated/dispatcher.rb +0 -28
  154. data/lib/action_controller/deprecated/url_writer.rb +0 -14
  155. data/lib/action_dispatch/routing/deprecated_mapper.rb +0 -525
  156. data/lib/action_view/helpers/prototype_helper.rb +0 -851
  157. data/lib/action_view/helpers/raw_output_helper.rb +0 -18
  158. data/lib/action_view/helpers/scriptaculous_helper.rb +0 -263
  159. data/lib/action_view/render/layouts.rb +0 -83
  160. data/lib/action_view/render/rendering.rb +0 -67
  161. data/lib/action_view/template/handlers/rjs.rb +0 -17
@@ -14,7 +14,7 @@ module AbstractController
14
14
  # Override AbstractController::Base's process_action to run the
15
15
  # process_action callbacks around the normal behavior.
16
16
  def process_action(method_name, *args)
17
- run_callbacks(:process_action, action_name) do
17
+ run_callbacks(:process_action, method_name) do
18
18
  super
19
19
  end
20
20
  end
@@ -29,7 +29,7 @@ module AbstractController
29
29
  #
30
30
  # ==== Options
31
31
  # * <tt>only</tt> - The callback should be run only for this action
32
- # * <tt>except<tt> - The callback should be run for all actions except this action
32
+ # * <tt>except</tt> - The callback should be run for all actions except this action
33
33
  def _normalize_callback_options(options)
34
34
  if only = options[:only]
35
35
  only = Array(only).map {|o| "action_name == '#{o}'"}.join(" || ")
@@ -81,29 +81,29 @@ module AbstractController
81
81
  class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
82
82
  # Append a before, after or around filter. See _insert_callbacks
83
83
  # for details on the allowed parameters.
84
- def #{filter}_filter(*names, &blk) # def before_filter(*names, &blk)
85
- _insert_callbacks(names, blk) do |name, options| # _insert_callbacks(names, blk) do |name, options}
86
- options[:if]=(Array.wrap(options[:if]) << "!halted") if #{filter == :after}
87
- set_callback(:process_action, :#{filter}, name, options) # set_callback(:process_action, :before_filter, name, options)
88
- end # end
89
- end # end
84
+ def #{filter}_filter(*names, &blk)
85
+ _insert_callbacks(names, blk) do |name, options|
86
+ options[:if] = (Array.wrap(options[:if]) << "!halted") if #{filter == :after}
87
+ set_callback(:process_action, :#{filter}, name, options)
88
+ end
89
+ end
90
90
 
91
91
  # Prepend a before, after or around filter. See _insert_callbacks
92
92
  # for details on the allowed parameters.
93
- def prepend_#{filter}_filter(*names, &blk) # def prepend_before_filter(*names, &blk)
94
- _insert_callbacks(names, blk) do |name, options| # _insert_callbacks(names, blk) do |name, options|
95
- options[:if]=(Array.wrap(options[:if]) << "!halted") if #{filter == :after}
96
- set_callback(:process_action, :#{filter}, name, options.merge(:prepend => true)) # set_callback(:process_action, :before, name, options.merge(:prepend => true))
97
- end # end
98
- end # end
93
+ def prepend_#{filter}_filter(*names, &blk)
94
+ _insert_callbacks(names, blk) do |name, options|
95
+ options[:if] = (Array.wrap(options[:if]) << "!halted") if #{filter == :after}
96
+ set_callback(:process_action, :#{filter}, name, options.merge(:prepend => true))
97
+ end
98
+ end
99
99
 
100
100
  # Skip a before, after or around filter. See _insert_callbacks
101
101
  # for details on the allowed parameters.
102
- def skip_#{filter}_filter(*names, &blk) # def skip_before_filter(*names, &blk)
103
- _insert_callbacks(names, blk) do |name, options| # _insert_callbacks(names, blk) do |name, options|
104
- skip_callback(:process_action, :#{filter}, name, options) # skip_callback(:process_action, :before, name, options)
105
- end # end
106
- end # end
102
+ def skip_#{filter}_filter(*names, &blk)
103
+ _insert_callbacks(names, blk) do |name, options|
104
+ skip_callback(:process_action, :#{filter}, name, options)
105
+ end
106
+ end
107
107
 
108
108
  # *_filter is the same as append_*_filter
109
109
  alias_method :append_#{filter}_filter, :#{filter}_filter
@@ -4,8 +4,6 @@ module AbstractController
4
4
  module Helpers
5
5
  extend ActiveSupport::Concern
6
6
 
7
- include Rendering
8
-
9
7
  included do
10
8
  class_attribute :_helpers
11
9
  self._helpers = Module.new
@@ -112,17 +110,6 @@ module AbstractController
112
110
  default_helper_module! unless anonymous?
113
111
  end
114
112
 
115
- private
116
- # Makes all the (instance) methods in the helper module available to templates
117
- # rendered through this controller.
118
- #
119
- # ==== Parameters
120
- # * <tt>module</tt> - The module to include into the current helper module
121
- # for the class
122
- def add_template_helper(mod)
123
- _helpers.module_eval { include mod }
124
- end
125
-
126
113
  # Returns a list of modules, normalized from the acceptable kinds of
127
114
  # helpers with the following behavior:
128
115
  #
@@ -155,6 +142,17 @@ module AbstractController
155
142
  end
156
143
  end
157
144
 
145
+ private
146
+ # Makes all the (instance) methods in the helper module available to templates
147
+ # rendered through this controller.
148
+ #
149
+ # ==== Parameters
150
+ # * <tt>module</tt> - The module to include into the current helper module
151
+ # for the class
152
+ def add_template_helper(mod)
153
+ _helpers.module_eval { include mod }
154
+ end
155
+
158
156
  def default_helper_module!
159
157
  module_name = name.sub(/Controller$/, '')
160
158
  module_path = module_name.underscore
@@ -265,11 +265,11 @@ module AbstractController
265
265
  raise ArgumentError, "Layouts must be specified as a String, Symbol, false, or nil"
266
266
  when nil
267
267
  if name
268
- _prefix = "layouts" unless _implied_layout_name =~ /\blayouts/
268
+ _prefixes = _implied_layout_name =~ /\blayouts/ ? [] : ["layouts"]
269
269
 
270
270
  self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
271
271
  def _layout
272
- if template_exists?("#{_implied_layout_name}", #{_prefix.inspect})
272
+ if template_exists?("#{_implied_layout_name}", #{_prefixes.inspect})
273
273
  "#{_implied_layout_name}"
274
274
  else
275
275
  super
@@ -334,7 +334,7 @@ module AbstractController
334
334
  # ==== Parameters
335
335
  # * <tt>details</tt> - A list of details to restrict the search by. This
336
336
  # might include details like the format or locale of the template.
337
- # * <tt>require_logout</tt> - If this is true, raise an ArgumentError
337
+ # * <tt>require_layout</tt> - If this is true, raise an ArgumentError
338
338
  # with details about the fact that the exception could not be
339
339
  # found (defaults to false)
340
340
  #
@@ -344,8 +344,7 @@ module AbstractController
344
344
  begin
345
345
  layout_name = _layout if action_has_layout?
346
346
  rescue NameError => e
347
- raise NoMethodError,
348
- "You specified #{@_layout.inspect} as the layout, but no such method was found"
347
+ raise e, "Could not render layout: #{e.message}"
349
348
  end
350
349
 
351
350
  if require_layout && action_has_layout? && !layout_name
@@ -0,0 +1,18 @@
1
+ module AbstractController
2
+ module Railties
3
+ module RoutesHelpers
4
+ def self.with(routes)
5
+ Module.new do
6
+ define_method(:inherited) do |klass|
7
+ super(klass)
8
+ if namespace = klass.parents.detect {|m| m.respond_to?(:_railtie) }
9
+ klass.send(:include, namespace._railtie.routes.url_helpers)
10
+ else
11
+ klass.send(:include, routes.url_helpers)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,5 +1,6 @@
1
1
  require "abstract_controller/base"
2
2
  require "action_view"
3
+ require "active_support/core_ext/object/instance_variables"
3
4
 
4
5
  module AbstractController
5
6
  class DoubleRenderError < Error
@@ -12,7 +13,6 @@ module AbstractController
12
13
 
13
14
  # This is a class to fix I18n global state. Whenever you provide I18n.locale during a request,
14
15
  # it will trigger the lookup_context and consequently expire the cache.
15
- # TODO Add some deprecation warnings to remove I18n.locale from controllers
16
16
  class I18nProxy < ::I18n::Config #:nodoc:
17
17
  attr_reader :original_config, :lookup_context
18
18
 
@@ -46,19 +46,9 @@ module AbstractController
46
46
  module ClassMethods
47
47
  def view_context_class
48
48
  @view_context_class ||= begin
49
- controller = self
50
- Class.new(ActionView::Base) do
51
- if controller.respond_to?(:_routes)
52
- include controller._routes.url_helpers
53
- end
54
-
55
- if controller.respond_to?(:_helpers)
56
- include controller._helpers
57
-
58
- # TODO: Fix RJS to not require this
59
- self.helpers = controller._helpers
60
- end
61
- end
49
+ routes = _routes if respond_to?(:_routes)
50
+ helpers = _helpers if respond_to?(:_helpers)
51
+ ActionView::Base.prepare(routes, helpers)
62
52
  end
63
53
  end
64
54
  end
@@ -84,21 +74,26 @@ module AbstractController
84
74
  #
85
75
  # Override this method in a module to change the default behavior.
86
76
  def view_context
87
- view_context_class.new(lookup_context, view_assigns, self)
77
+ view_context_class.new(view_renderer, view_assigns, self)
78
+ end
79
+
80
+ # Returns an object that is able to render templates.
81
+ def view_renderer
82
+ @view_renderer ||= ActionView::Renderer.new(lookup_context)
88
83
  end
89
84
 
90
85
  # Normalize arguments, options and then delegates render_to_body and
91
86
  # sticks the result in self.response_body.
92
87
  def render(*args, &block)
93
- self.response_body = render_to_string(*args, &block)
88
+ options = _normalize_render(*args, &block)
89
+ self.response_body = render_to_body(options)
94
90
  end
95
91
 
96
92
  # Raw rendering of a template to a string. Just convert the results of
97
- # render_to_body into a String.
93
+ # render_response into a String.
98
94
  # :api: plugin
99
95
  def render_to_string(*args, &block)
100
- options = _normalize_args(*args, &block)
101
- _normalize_options(options)
96
+ options = _normalize_render(*args, &block)
102
97
  render_to_body(options)
103
98
  end
104
99
 
@@ -112,15 +107,10 @@ module AbstractController
112
107
  # Find and renders a template based on the options given.
113
108
  # :api: private
114
109
  def _render_template(options) #:nodoc:
115
- view_context.render(options)
110
+ view_renderer.render(view_context, options)
116
111
  end
117
112
 
118
- # The prefix used in render "foo" shortcuts.
119
- def _prefix
120
- controller_path
121
- end
122
-
123
- private
113
+ private
124
114
 
125
115
  # This method should return a hash with assigns.
126
116
  # You can overwrite this configuration per controller.
@@ -129,41 +119,54 @@ module AbstractController
129
119
  hash = {}
130
120
  variables = instance_variable_names
131
121
  variables -= protected_instance_variables if respond_to?(:protected_instance_variables)
132
- variables.each { |name| hash[name.to_s[1..-1]] = instance_variable_get(name) }
122
+ variables.each { |name| hash[name.to_s[1, name.length]] = instance_variable_get(name) }
133
123
  hash
134
124
  end
135
125
 
136
- # Normalize options by converting render "foo" to render :action => "foo" and
126
+ # Normalize args and options.
127
+ # :api: private
128
+ def _normalize_render(*args, &block)
129
+ options = _normalize_args(*args, &block)
130
+ _normalize_options(options)
131
+ options
132
+ end
133
+
134
+ # Normalize args by converting render "foo" to render :action => "foo" and
137
135
  # render "foo/bar" to render :file => "foo/bar".
136
+ # :api: plugin
138
137
  def _normalize_args(action=nil, options={})
139
138
  case action
140
139
  when NilClass
141
140
  when Hash
142
- options, action = action, nil
141
+ options = action
143
142
  when String, Symbol
144
143
  action = action.to_s
145
144
  key = action.include?(?/) ? :file : :action
146
145
  options[key] = action
147
146
  else
148
- options.merge!(:partial => action)
147
+ options[:partial] = action
149
148
  end
150
149
 
151
150
  options
152
151
  end
153
152
 
153
+ # Normalize options.
154
+ # :api: plugin
154
155
  def _normalize_options(options)
155
156
  if options[:partial] == true
156
157
  options[:partial] = action_name
157
158
  end
158
159
 
159
160
  if (options.keys & [:partial, :file, :template]).empty?
160
- options[:prefix] ||= _prefix
161
+ options[:prefixes] ||= _prefixes
161
162
  end
162
163
 
163
164
  options[:template] ||= (options[:action] || action_name).to_s
164
165
  options
165
166
  end
166
167
 
168
+ # Process extra options.
169
+ # :api: plugin
167
170
  def _process_options(options)
168
171
  end
169
172
  end
@@ -0,0 +1,27 @@
1
+ module AbstractController
2
+ module UrlFor
3
+ extend ActiveSupport::Concern
4
+ include ActionDispatch::Routing::UrlFor
5
+
6
+ def _routes
7
+ raise "In order to use #url_for, you must include routing helpers explicitly. " \
8
+ "For instance, `include Rails.application.routes.url_helpers"
9
+ end
10
+
11
+ module ClassMethods
12
+ def _routes
13
+ nil
14
+ end
15
+
16
+ def action_methods
17
+ @action_methods ||= begin
18
+ if _routes
19
+ super - _routes.named_routes.helper_names
20
+ else
21
+ super
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -11,11 +11,36 @@ module AbstractController
11
11
  delegate :find_template, :template_exists?, :view_paths, :formats, :formats=,
12
12
  :locale, :locale=, :to => :lookup_context
13
13
 
14
+ module ClassMethods
15
+ def parent_prefixes
16
+ @parent_prefixes ||= begin
17
+ parent_controller = superclass
18
+ prefixes = []
19
+
20
+ until parent_controller.abstract?
21
+ prefixes << parent_controller.controller_path
22
+ parent_controller = parent_controller.superclass
23
+ end
24
+
25
+ prefixes
26
+ end
27
+ end
28
+ end
29
+
30
+ # The prefixes used in render "foo" shortcuts.
31
+ def _prefixes
32
+ @_prefixes ||= begin
33
+ parent_prefixes = self.class.parent_prefixes
34
+ parent_prefixes.dup.unshift(controller_path)
35
+ end
36
+ end
37
+
14
38
  # LookupContext is the object responsible to hold all information required to lookup
15
39
  # templates, i.e. view paths and details. Check ActionView::LookupContext for more
16
40
  # information.
17
41
  def lookup_context
18
- @lookup_context ||= ActionView::LookupContext.new(self.class._view_paths, details_for_lookup)
42
+ @lookup_context ||=
43
+ ActionView::LookupContext.new(self.class._view_paths, details_for_lookup, _prefixes)
19
44
  end
20
45
 
21
46
  def details_for_lookup
@@ -36,7 +61,7 @@ module AbstractController
36
61
  # ==== Parameters
37
62
  # * <tt>path</tt> - If a String is provided, it gets converted into
38
63
  # the default view path. You may also provide a custom view path
39
- # (see ActionView::ViewPathSet for more information)
64
+ # (see ActionView::PathSet for more information)
40
65
  def append_view_path(path)
41
66
  self.view_paths = view_paths.dup + Array(path)
42
67
  end
@@ -46,7 +71,7 @@ module AbstractController
46
71
  # ==== Parameters
47
72
  # * <tt>path</tt> - If a String is provided, it gets converted into
48
73
  # the default view path. You may also provide a custom view path
49
- # (see ActionView::ViewPathSet for more information)
74
+ # (see ActionView::PathSet for more information)
50
75
  def prepend_view_path(path)
51
76
  self.view_paths = Array(path) + view_paths.dup
52
77
  end
@@ -59,12 +84,12 @@ module AbstractController
59
84
  # Set the view paths.
60
85
  #
61
86
  # ==== Parameters
62
- # * <tt>paths</tt> - If a ViewPathSet is provided, use that;
63
- # otherwise, process the parameter into a ViewPathSet.
87
+ # * <tt>paths</tt> - If a PathSet is provided, use that;
88
+ # otherwise, process the parameter into a PathSet.
64
89
  def view_paths=(paths)
65
90
  self._view_paths = ActionView::Base.process_view_paths(paths)
66
91
  self._view_paths.freeze
67
92
  end
68
93
  end
69
94
  end
70
- end
95
+ end
@@ -13,7 +13,9 @@ module ActionController
13
13
  autoload :Compatibility
14
14
  autoload :ConditionalGet
15
15
  autoload :Cookies
16
+ autoload :DataStreaming
16
17
  autoload :Flash
18
+ autoload :ForceSSL
17
19
  autoload :Head
18
20
  autoload :Helpers
19
21
  autoload :HideActions
@@ -21,6 +23,7 @@ module ActionController
21
23
  autoload :ImplicitRender
22
24
  autoload :Instrumentation
23
25
  autoload :MimeResponds
26
+ autoload :ParamsWrapper
24
27
  autoload :RackDelegation
25
28
  autoload :Redirecting
26
29
  autoload :Renderers
@@ -34,12 +37,10 @@ module ActionController
34
37
  autoload :UrlFor
35
38
  end
36
39
 
37
- autoload :Dispatcher, 'action_controller/deprecated/dispatcher'
38
- autoload :UrlWriter, 'action_controller/deprecated/url_writer'
39
- autoload :UrlRewriter, 'action_controller/deprecated/url_writer'
40
40
  autoload :Integration, 'action_controller/deprecated/integration_test'
41
41
  autoload :IntegrationTest, 'action_controller/deprecated/integration_test'
42
42
  autoload :PerformanceTest, 'action_controller/deprecated/performance_test'
43
+ autoload :UrlWriter, 'action_controller/deprecated'
43
44
  autoload :Routing, 'action_controller/deprecated'
44
45
  autoload :TestCase, 'action_controller/test_case'
45
46
 
@@ -74,4 +75,5 @@ require 'active_support/core_ext/load_error'
74
75
  require 'active_support/core_ext/module/attr_internal'
75
76
  require 'active_support/core_ext/module/delegation'
76
77
  require 'active_support/core_ext/name_error'
78
+ require 'active_support/core_ext/uri'
77
79
  require 'active_support/inflector'
@@ -24,7 +24,7 @@ module ActionController
24
24
  #
25
25
  # Actions, by default, render a template in the <tt>app/views</tt> directory corresponding to the name of the controller and action
26
26
  # after executing code in the action. For example, the +index+ action of the PostsController would render the
27
- # template <tt>app/views/posts/index.erb</tt> by default after populating the <tt>@posts</tt> instance variable.
27
+ # template <tt>app/views/posts/index.html.erb</tt> by default after populating the <tt>@posts</tt> instance variable.
28
28
  #
29
29
  # Unlike index, the create action will not render a template. After performing its main purpose (creating a
30
30
  # new post), it initiates a redirect instead. This redirect works by returning an external
@@ -93,9 +93,9 @@ module ActionController
93
93
  # * ActiveRecord::SessionStore - Sessions are stored in your database, which works better than PStore with multiple app servers and,
94
94
  # unlike CookieStore, hides your session contents from the user. To use ActiveRecord::SessionStore, set
95
95
  #
96
- # config.action_controller.session_store = :active_record_store
96
+ # MyApplication::Application.config.session_store :active_record_store
97
97
  #
98
- # in your <tt>config/environment.rb</tt> and run <tt>rake db:sessions:create</tt>.
98
+ # in your <tt>config/initializers/session_store.rb</tt> and run <tt>script/rails g session_migration</tt>.
99
99
  #
100
100
  # == Responses
101
101
  #
@@ -105,7 +105,7 @@ module ActionController
105
105
  # == Renders
106
106
  #
107
107
  # Action Controller sends content to the user by using one of five rendering methods. The most versatile and common is the rendering
108
- # of a template. Included in the Action Pack is the Action View, which enables rendering of ERb templates. It's automatically configured.
108
+ # of a template. Included in the Action Pack is the Action View, which enables rendering of ERB templates. It's automatically configured.
109
109
  # The controller passes objects to the view by assigning instance variables:
110
110
  #
111
111
  # def show
@@ -128,7 +128,7 @@ module ActionController
128
128
  # end
129
129
  # end
130
130
  #
131
- # Read more about writing ERb and Builder templates in ActionView::Base.
131
+ # Read more about writing ERB and Builder templates in ActionView::Base.
132
132
  #
133
133
  # == Redirects
134
134
  #
@@ -198,7 +198,9 @@ module ActionController
198
198
  Cookies,
199
199
  Flash,
200
200
  RequestForgeryProtection,
201
+ ForceSSL,
201
202
  Streaming,
203
+ DataStreaming,
202
204
  RecordIdentifier,
203
205
  HttpAuthentication::Basic::ControllerMethods,
204
206
  HttpAuthentication::Digest::ControllerMethods,
@@ -208,12 +210,16 @@ module ActionController
208
210
  # also include them at the bottom.
209
211
  AbstractController::Callbacks,
210
212
 
211
- # The same with rescue, append it at the end to wrap as much as possible.
212
- Rescue,
213
-
214
213
  # Add instrumentations hooks at the bottom, to ensure they instrument
215
214
  # all the methods properly.
216
- Instrumentation
215
+ Instrumentation,
216
+
217
+ # Params wrapper should come before instrumentation so they are
218
+ # properly showed in logs
219
+ ParamsWrapper,
220
+
221
+ # The same with rescue, append it at the end to wrap as much as possible.
222
+ Rescue
217
223
  ]
218
224
 
219
225
  MODULES.each do |mod|
@@ -223,13 +229,6 @@ module ActionController
223
229
  # Rails 2.x compatibility
224
230
  include ActionController::Compatibility
225
231
 
226
- def self.inherited(klass)
227
- super
228
- klass.helper :all if klass.superclass == ActionController::Base
229
- end
230
-
231
- require "action_controller/deprecated/base"
232
232
  ActiveSupport.run_load_hooks(:action_controller, self)
233
233
  end
234
234
  end
235
-