actionpack 3.1.12 → 3.2.0.rc1

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 (128) hide show
  1. data/CHANGELOG.md +5503 -108
  2. data/README.rdoc +3 -3
  3. data/lib/abstract_controller/asset_paths.rb +1 -1
  4. data/lib/abstract_controller/base.rb +1 -1
  5. data/lib/abstract_controller/callbacks.rb +102 -18
  6. data/lib/abstract_controller/helpers.rb +1 -1
  7. data/lib/abstract_controller/layouts.rb +116 -50
  8. data/lib/abstract_controller/logger.rb +1 -1
  9. data/lib/abstract_controller/railties/routes_helpers.rb +2 -2
  10. data/lib/abstract_controller/rendering.rb +1 -6
  11. data/lib/abstract_controller/view_paths.rb +6 -5
  12. data/lib/action_controller.rb +0 -15
  13. data/lib/action_controller/caching.rb +0 -1
  14. data/lib/action_controller/caching/actions.rb +5 -6
  15. data/lib/action_controller/caching/fragments.rb +18 -18
  16. data/lib/action_controller/caching/pages.rb +7 -6
  17. data/lib/action_controller/caching/sweeping.rb +1 -1
  18. data/lib/action_controller/log_subscriber.rb +8 -4
  19. data/lib/action_controller/metal.rb +7 -1
  20. data/lib/action_controller/metal/conditional_get.rb +49 -4
  21. data/lib/action_controller/metal/data_streaming.rb +17 -5
  22. data/lib/action_controller/metal/force_ssl.rb +8 -5
  23. data/lib/action_controller/metal/helpers.rb +7 -4
  24. data/lib/action_controller/metal/http_authentication.rb +9 -12
  25. data/lib/action_controller/metal/instrumentation.rb +9 -4
  26. data/lib/action_controller/metal/mime_responds.rb +4 -4
  27. data/lib/action_controller/metal/params_wrapper.rb +12 -8
  28. data/lib/action_controller/metal/redirecting.rb +7 -6
  29. data/lib/action_controller/metal/renderers.rb +9 -11
  30. data/lib/action_controller/metal/request_forgery_protection.rb +2 -1
  31. data/lib/action_controller/metal/rescue.rb +13 -0
  32. data/lib/action_controller/metal/responder.rb +11 -23
  33. data/lib/action_controller/metal/streaming.rb +0 -25
  34. data/lib/action_controller/railtie.rb +1 -0
  35. data/lib/action_controller/railties/paths.rb +4 -3
  36. data/lib/action_controller/record_identifier.rb +4 -4
  37. data/lib/action_controller/test_case.rb +60 -56
  38. data/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +6 -6
  39. data/lib/action_dispatch.rb +5 -1
  40. data/lib/action_dispatch/http/cache.rb +27 -15
  41. data/lib/action_dispatch/http/filter_parameters.rb +3 -1
  42. data/lib/action_dispatch/http/headers.rb +3 -5
  43. data/lib/action_dispatch/http/mime_negotiation.rb +2 -1
  44. data/lib/action_dispatch/http/mime_type.rb +7 -3
  45. data/lib/action_dispatch/http/mime_types.rb +12 -0
  46. data/lib/action_dispatch/http/parameter_filter.rb +3 -1
  47. data/lib/action_dispatch/http/parameters.rb +0 -4
  48. data/lib/action_dispatch/http/request.rb +18 -68
  49. data/lib/action_dispatch/http/response.rb +11 -32
  50. data/lib/action_dispatch/http/upload.rb +3 -14
  51. data/lib/action_dispatch/http/url.rb +1 -1
  52. data/lib/action_dispatch/middleware/callbacks.rb +1 -2
  53. data/lib/action_dispatch/middleware/cookies.rb +20 -16
  54. data/lib/action_dispatch/middleware/debug_exceptions.rb +82 -0
  55. data/lib/action_dispatch/middleware/exception_wrapper.rb +78 -0
  56. data/lib/action_dispatch/middleware/flash.rb +6 -9
  57. data/lib/action_dispatch/middleware/params_parser.rb +6 -11
  58. data/lib/action_dispatch/middleware/public_exceptions.rb +30 -0
  59. data/lib/action_dispatch/middleware/reloader.rb +38 -14
  60. data/lib/action_dispatch/middleware/remote_ip.rb +66 -36
  61. data/lib/action_dispatch/middleware/request_id.rb +39 -0
  62. data/lib/action_dispatch/middleware/session/abstract_store.rb +4 -16
  63. data/lib/action_dispatch/middleware/session/cache_store.rb +50 -0
  64. data/lib/action_dispatch/middleware/session/cookie_store.rb +1 -1
  65. data/lib/action_dispatch/middleware/show_exceptions.rb +58 -142
  66. data/lib/action_dispatch/middleware/static.rb +2 -10
  67. data/lib/action_dispatch/middleware/templates/rescues/layout.erb +1 -0
  68. data/lib/action_dispatch/middleware/templates/rescues/routing_error.erb +13 -8
  69. data/lib/action_dispatch/railtie.rb +15 -1
  70. data/lib/action_dispatch/routing.rb +1 -2
  71. data/lib/action_dispatch/routing/mapper.rb +108 -107
  72. data/lib/action_dispatch/routing/redirection.rb +63 -69
  73. data/lib/action_dispatch/routing/route_set.rb +75 -43
  74. data/lib/action_dispatch/routing/routes_proxy.rb +0 -4
  75. data/lib/action_dispatch/routing/url_for.rb +3 -3
  76. data/lib/action_dispatch/testing/assertions/response.rb +5 -7
  77. data/lib/action_dispatch/testing/assertions/routing.rb +10 -9
  78. data/lib/action_dispatch/testing/integration.rb +8 -25
  79. data/lib/action_dispatch/testing/test_process.rb +3 -2
  80. data/lib/action_dispatch/testing/test_request.rb +4 -23
  81. data/lib/action_pack/version.rb +3 -3
  82. data/lib/action_view.rb +1 -5
  83. data/lib/action_view/asset_paths.rb +7 -8
  84. data/lib/action_view/base.rb +7 -5
  85. data/lib/action_view/helpers/asset_paths.rb +1 -1
  86. data/lib/action_view/helpers/asset_tag_helper.rb +4 -8
  87. data/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb +3 -0
  88. data/lib/action_view/helpers/atom_feed_helper.rb +2 -2
  89. data/lib/action_view/helpers/capture_helper.rb +3 -3
  90. data/lib/action_view/helpers/controller_helper.rb +1 -1
  91. data/lib/action_view/helpers/date_helper.rb +26 -18
  92. data/lib/action_view/helpers/debug_helper.rb +1 -1
  93. data/lib/action_view/helpers/form_helper.rb +71 -13
  94. data/lib/action_view/helpers/form_options_helper.rb +65 -34
  95. data/lib/action_view/helpers/form_tag_helper.rb +24 -18
  96. data/lib/action_view/helpers/javascript_helper.rb +12 -3
  97. data/lib/action_view/helpers/number_helper.rb +3 -2
  98. data/lib/action_view/helpers/record_tag_helper.rb +51 -5
  99. data/lib/action_view/helpers/rendering_helper.rb +2 -2
  100. data/lib/action_view/helpers/sanitize_helper.rb +6 -7
  101. data/lib/action_view/helpers/tag_helper.rb +1 -1
  102. data/lib/action_view/helpers/text_helper.rb +5 -4
  103. data/lib/action_view/helpers/url_helper.rb +19 -11
  104. data/lib/action_view/locale/en.yml +6 -0
  105. data/lib/action_view/log_subscriber.rb +1 -1
  106. data/lib/action_view/lookup_context.rb +123 -125
  107. data/lib/action_view/path_set.rb +60 -13
  108. data/lib/action_view/renderer/abstract_renderer.rb +16 -11
  109. data/lib/action_view/renderer/partial_renderer.rb +59 -40
  110. data/lib/action_view/renderer/template_renderer.rb +29 -17
  111. data/lib/action_view/template.rb +0 -1
  112. data/lib/action_view/template/error.rb +6 -5
  113. data/lib/action_view/template/handlers.rb +0 -6
  114. data/lib/action_view/template/handlers/builder.rb +10 -1
  115. data/lib/action_view/template/handlers/erb.rb +2 -2
  116. data/lib/action_view/template/resolver.rb +20 -31
  117. data/lib/action_view/test_case.rb +7 -10
  118. data/lib/sprockets/assets.rake +1 -1
  119. data/lib/sprockets/bootstrap.rb +3 -31
  120. data/lib/sprockets/compressors.rb +69 -7
  121. data/lib/sprockets/helpers/rails_helper.rb +6 -11
  122. data/lib/sprockets/railtie.rb +1 -0
  123. data/lib/sprockets/static_compiler.rb +0 -3
  124. metadata +57 -86
  125. checksums.yaml +0 -7
  126. data/lib/action_dispatch/middleware/closed_error.rb +0 -7
  127. data/lib/action_dispatch/routing/route.rb +0 -67
  128. data/lib/action_view/template/handler.rb +0 -49
@@ -7,9 +7,12 @@ module ActionController
7
7
  # by default.
8
8
  #
9
9
  # In addition to using the standard template helpers provided, creating custom helpers to
10
- # extract complicated logic or reusable functionality is strongly encouraged. By default, the controller will
11
- # include a helper whose name matches that of the controller, e.g., <tt>MyController</tt> will automatically
12
- # include <tt>MyHelper</tt>.
10
+ # extract complicated logic or reusable functionality is strongly encouraged. By default, each controller
11
+ # will include all helpers.
12
+ #
13
+ # In previous versions of \Rails the controller will include a helper whose
14
+ # name matches that of the controller, e.g., <tt>MyController</tt> will automatically
15
+ # include <tt>MyHelper</tt>. To return old behavior set +config.action_controller.include_all_helpers+ to +false+.
13
16
  #
14
17
  # Additional helpers can be specified using the +helper+ class method in ActionController::Base or any
15
18
  # controller which inherits from it.
@@ -29,7 +32,7 @@ module ActionController
29
32
  # class EventsController < ActionController::Base
30
33
  # helper FormattedTimeHelper
31
34
  # def index
32
- # @events = Event.find(:all)
35
+ # @events = Event.all
33
36
  # end
34
37
  # end
35
38
  #
@@ -192,15 +192,12 @@ module ActionController
192
192
  return false unless password
193
193
 
194
194
  method = request.env['rack.methodoverride.original_method'] || request.env['REQUEST_METHOD']
195
- uri = credentials[:uri][0,1] == '/' ? request.original_fullpath : request.original_url
195
+ uri = credentials[:uri][0,1] == '/' ? request.fullpath : request.url
196
196
 
197
- [true, false].any? do |trailing_question_mark|
198
- [true, false].any? do |password_is_ha1|
199
- _uri = trailing_question_mark ? uri + "?" : uri
200
- expected = expected_response(method, _uri, credentials, password, password_is_ha1)
201
- expected == credentials[:response]
202
- end
203
- end
197
+ [true, false].any? do |password_is_ha1|
198
+ expected = expected_response(method, uri, credentials, password, password_is_ha1)
199
+ expected == credentials[:response]
200
+ end
204
201
  end
205
202
  end
206
203
 
@@ -227,9 +224,9 @@ module ActionController
227
224
  end
228
225
 
229
226
  def decode_credentials(header)
230
- HashWithIndifferentAccess[header.to_s.gsub(/^Digest\s+/,'').split(',').map do |pair|
227
+ Hash[header.to_s.gsub(/^Digest\s+/,'').split(',').map do |pair|
231
228
  key, value = pair.split('=', 2)
232
- [key.strip, value.to_s.gsub(/^"|"$/,'').delete('\'')]
229
+ [key.strip.to_sym, value.to_s.gsub(/^"|"$/,'').gsub(/'/, '')]
233
230
  end]
234
231
  end
235
232
 
@@ -403,7 +400,7 @@ module ActionController
403
400
  # the present token and options.
404
401
  #
405
402
  # controller - ActionController::Base instance for the current request.
406
- # login_procedure - Proc to call if a token is present. The Proc should
403
+ # login_procedure - Proc to call if a token is present. The Proc should
407
404
  # take 2 arguments:
408
405
  # authenticate(controller) { |token, options| ... }
409
406
  #
@@ -416,7 +413,7 @@ module ActionController
416
413
  end
417
414
  end
418
415
 
419
- # Parses the token and options out of the token authorization header. If
416
+ # Parses the token and options out of the token authorization header. If
420
417
  # the header looks like this:
421
418
  # Authorization: Token token="abc", nonce="def"
422
419
  # Then the returned token is "abc", and the options is {:nonce => "def"}
@@ -58,13 +58,18 @@ module ActionController
58
58
  def redirect_to(*args)
59
59
  ActiveSupport::Notifications.instrument("redirect_to.action_controller") do |payload|
60
60
  result = super
61
- payload[:status] = self.status
62
- payload[:location] = self.location
61
+ payload[:status] = response.status
62
+ payload[:location] = response.location
63
63
  result
64
64
  end
65
65
  end
66
66
 
67
- protected
67
+ private
68
+
69
+ # A hook invoked everytime a before callback is halted.
70
+ def halted_callback_hook(filter)
71
+ ActiveSupport::Notifications.instrument("halted_callback.action_controller", :filter => filter)
72
+ end
68
73
 
69
74
  # A hook which allows you to clean up any time taken into account in
70
75
  # views wrongly, like database querying time.
@@ -97,4 +102,4 @@ module ActionController
97
102
  end
98
103
  end
99
104
  end
100
- end
105
+ end
@@ -42,8 +42,8 @@ module ActionController #:nodoc:
42
42
  def respond_to(*mimes)
43
43
  options = mimes.extract_options!
44
44
 
45
- only_actions = Array(options.delete(:only))
46
- except_actions = Array(options.delete(:except))
45
+ only_actions = Array(options.delete(:only)).map(&:to_s)
46
+ except_actions = Array(options.delete(:except)).map(&:to_s)
47
47
 
48
48
  new = mimes_for_respond_to.dup
49
49
  mimes.each do |mime|
@@ -182,7 +182,7 @@ module ActionController #:nodoc:
182
182
  #
183
183
  # def index
184
184
  # @people = Person.all
185
- # respond_with(@person)
185
+ # respond_with(@people)
186
186
  # end
187
187
  # end
188
188
  #
@@ -245,7 +245,7 @@ module ActionController #:nodoc:
245
245
  # current action.
246
246
  #
247
247
  def collect_mimes_from_class_level #:nodoc:
248
- action = action_name.to_sym
248
+ action = action_name.to_s
249
249
 
250
250
  self.class.mimes_for_respond_to.keys.select do |mime|
251
251
  config = self.class.mimes_for_respond_to[mime]
@@ -43,6 +43,11 @@ module ActionController
43
43
  # wrap_parameters :person, :include => [:username, :password]
44
44
  # end
45
45
  #
46
+ # On ActiveRecord models with no +:include+ or +:exclude+ option set,
47
+ # if attr_accessible is set on that model, it will only wrap the accessible
48
+ # parameters, else it will only wrap the parameters returned by the class
49
+ # method attribute_names.
50
+ #
46
51
  # If you're going to pass the parameters to an +ActiveModel+ object (such as
47
52
  # +User.new(params[:user])+), you might consider passing the model class to
48
53
  # the method instead. The +ParamsWrapper+ will actually try to determine the
@@ -141,19 +146,16 @@ module ActionController
141
146
  # try to find Foo::Bar::User, Foo::User and finally User.
142
147
  def _default_wrap_model #:nodoc:
143
148
  return nil if self.anonymous?
144
-
145
- model_name = self.name.sub(/Controller$/, '').singularize
149
+ model_name = self.name.sub(/Controller$/, '').classify
146
150
 
147
151
  begin
148
- model_klass = model_name.constantize
149
- rescue NameError, ArgumentError => e
150
- if e.message =~ /is not missing constant|uninitialized constant #{model_name}/
152
+ if model_klass = model_name.safe_constantize
153
+ model_klass
154
+ else
151
155
  namespaces = model_name.split("::")
152
156
  namespaces.delete_at(-2)
153
157
  break if namespaces.last == model_name
154
158
  model_name = namespaces.join("::")
155
- else
156
- raise
157
159
  end
158
160
  end until model_klass
159
161
 
@@ -165,7 +167,9 @@ module ActionController
165
167
 
166
168
  unless options[:include] || options[:exclude]
167
169
  model ||= _default_wrap_model
168
- if model.respond_to?(:attribute_names) && model.attribute_names.present?
170
+ if model.respond_to?(:accessible_attributes) && model.accessible_attributes.present?
171
+ options[:include] = model.accessible_attributes.to_a
172
+ elsif model.respond_to?(:attribute_names) && model.attribute_names.present?
169
173
  options[:include] = model.attribute_names
170
174
  end
171
175
  end
@@ -18,7 +18,7 @@ module ActionController
18
18
  #
19
19
  # * <tt>Hash</tt> - The URL will be generated by calling url_for with the +options+.
20
20
  # * <tt>Record</tt> - The URL will be generated by calling url_for with the +options+, which will reference a named URL for that record.
21
- # * <tt>String</tt> starting with <tt>protocol://</tt> (like <tt>http://</tt>) - Is passed straight through as the target for redirection.
21
+ # * <tt>String</tt> starting with <tt>protocol://</tt> (like <tt>http://</tt>) or a protocol relative reference (like <tt>//</tt>) - Is passed straight through as the target for redirection.
22
22
  # * <tt>String</tt> not containing a protocol - The current protocol and host is prepended to the string.
23
23
  # * <tt>Proc</tt> - A block that will be executed in the controller's context. Should return any option accepted by +redirect_to+.
24
24
  # * <tt>:back</tt> - Back to the page that issued the request. Useful for forms that are triggered from multiple places.
@@ -54,10 +54,10 @@ module ActionController
54
54
  # redirect_to post_url(@post), :status => 301, :flash => { :updated_post_id => @post.id }
55
55
  # redirect_to { :action=>'atom' }, :alert => "Something serious happened"
56
56
  #
57
- # When using <tt>redirect_to :back</tt>, if there is no referrer, RedirectBackError will be raised. You may specify some fallback
58
- # behavior for this case by rescuing RedirectBackError.
57
+ # When using <tt>redirect_to :back</tt>, if there is no referrer, ActionController::RedirectBackError will be raised. You may specify some fallback
58
+ # behavior for this case by rescuing ActionController::RedirectBackError.
59
59
  def redirect_to(options = {}, response_status = {}) #:doc:
60
- raise ActionControllerError.new("Cannot redirect to nil!") if options.nil?
60
+ raise ActionControllerError.new("Cannot redirect to nil!") unless options
61
61
  raise AbstractController::DoubleRenderError if response_body
62
62
 
63
63
  self.status = _extract_redirect_to_status(options, response_status)
@@ -81,7 +81,8 @@ module ActionController
81
81
  # The scheme name consist of a letter followed by any combination of
82
82
  # letters, digits, and the plus ("+"), period ("."), or hyphen ("-")
83
83
  # characters; and is terminated by a colon (":").
84
- when %r{^\w[\w+.-]*:.*}
84
+ # The protocol relative scheme starts with a double slash "//"
85
+ when %r{^(\w[\w+.-]*:|//).*}
85
86
  options
86
87
  when String
87
88
  request.protocol + request.host_with_port + options
@@ -92,7 +93,7 @@ module ActionController
92
93
  _compute_redirect_to_location options.call
93
94
  else
94
95
  url_for(options)
95
- end.gsub(/[\0\r\n]/, '')
96
+ end.gsub(/[\r\n]/, '')
96
97
  end
97
98
  end
98
99
  end
@@ -1,5 +1,6 @@
1
1
  require 'active_support/core_ext/class/attribute'
2
2
  require 'active_support/core_ext/object/blank'
3
+ require 'set'
3
4
 
4
5
  module ActionController
5
6
  # See <tt>Renderers.add</tt>
@@ -12,16 +13,13 @@ module ActionController
12
13
 
13
14
  included do
14
15
  class_attribute :_renderers
15
- self._renderers = {}.freeze
16
+ self._renderers = Set.new.freeze
16
17
  end
17
18
 
18
19
  module ClassMethods
19
20
  def use_renderers(*args)
20
- new = _renderers.dup
21
- args.each do |key|
22
- new[key] = RENDERERS[key]
23
- end
24
- self._renderers = new.freeze
21
+ renderers = _renderers + args
22
+ self._renderers = renderers.freeze
25
23
  end
26
24
  alias use_renderer use_renderers
27
25
  end
@@ -31,10 +29,10 @@ module ActionController
31
29
  end
32
30
 
33
31
  def _handle_render_options(options)
34
- _renderers.each do |name, value|
35
- if options.key?(name.to_sym)
32
+ _renderers.each do |name|
33
+ if options.key?(name)
36
34
  _process_options(options)
37
- return send("_render_option_#{name}", options.delete(name.to_sym), options)
35
+ return send("_render_option_#{name}", options.delete(name), options)
38
36
  end
39
37
  end
40
38
  nil
@@ -42,7 +40,7 @@ module ActionController
42
40
 
43
41
  # Hash of available renderers, mapping a renderer name to its proc.
44
42
  # Default keys are :json, :js, :xml.
45
- RENDERERS = {}
43
+ RENDERERS = Set.new
46
44
 
47
45
  # Adds a new renderer to call within controller actions.
48
46
  # A renderer is invoked by passing its name as an option to
@@ -79,7 +77,7 @@ module ActionController
79
77
  # <tt>ActionController::MimeResponds#respond_with</tt>
80
78
  def self.add(key, &block)
81
79
  define_method("_render_option_#{key}", &block)
82
- RENDERERS[key] = block
80
+ RENDERERS << key.to_sym
83
81
  end
84
82
 
85
83
  module All
@@ -1,4 +1,5 @@
1
1
  require 'active_support/core_ext/class/attribute'
2
+ require 'action_controller/metal/exceptions'
2
3
 
3
4
  module ActionController #:nodoc:
4
5
  class InvalidAuthenticityToken < ActionControllerError #:nodoc:
@@ -73,7 +74,7 @@ module ActionController #:nodoc:
73
74
  # The actual before_filter that is used. Modify this to change how you handle unverified requests.
74
75
  def verify_authenticity_token
75
76
  unless verified_request?
76
- logger.debug "WARNING: Can't verify CSRF token authenticity" if logger
77
+ logger.warn "WARNING: Can't verify CSRF token authenticity" if logger
77
78
  handle_unverified_request
78
79
  end
79
80
  end
@@ -1,4 +1,7 @@
1
1
  module ActionController #:nodoc:
2
+ # This module is responsible to provide `rescue_from` helpers
3
+ # to controllers and configure when detailed exceptions must be
4
+ # shown.
2
5
  module Rescue
3
6
  extend ActiveSupport::Concern
4
7
  include ActiveSupport::Rescuable
@@ -12,10 +15,20 @@ module ActionController #:nodoc:
12
15
  super(exception)
13
16
  end
14
17
 
18
+ # Override this method if you want to customize when detailed
19
+ # exceptions must be shown. This method is only called when
20
+ # consider_all_requests_local is false. By default, it returns
21
+ # false, but someone may set it to `request.local?` so local
22
+ # requests in production still shows the detailed exception pages.
23
+ def show_detailed_exceptions?
24
+ false
25
+ end
26
+
15
27
  private
16
28
  def process_action(*args)
17
29
  super
18
30
  rescue Exception => exception
31
+ request.env['action_dispatch.show_detailed_exceptions'] ||= show_detailed_exceptions?
19
32
  rescue_with_handler(exception) || raise(exception)
20
33
  end
21
34
  end
@@ -9,7 +9,7 @@ module ActionController #:nodoc:
9
9
  # respond_to :html, :xml, :json
10
10
  #
11
11
  # def index
12
- # @people = Person.find(:all)
12
+ # @people = Person.all
13
13
  # respond_with(@people)
14
14
  # end
15
15
  # end
@@ -84,8 +84,8 @@ module ActionController #:nodoc:
84
84
  #
85
85
  # === Custom options
86
86
  #
87
- # <code>respond_with</code> also allow you to pass options that are forwarded
88
- # to the underlying render call. Those options are only applied success
87
+ # <code>respond_with</code> also allows you to pass options that are forwarded
88
+ # to the underlying render call. Those options are only applied for success
89
89
  # scenarios. For instance, you can do the following in the create method above:
90
90
  #
91
91
  # def create
@@ -95,7 +95,7 @@ module ActionController #:nodoc:
95
95
  # respond_with(@project, @task, :status => 201)
96
96
  # end
97
97
  #
98
- # This will return status 201 if the task was saved with success. If not,
98
+ # This will return status 201 if the task was saved successfully. If not,
99
99
  # it will simply ignore the given options and return status 422 and the
100
100
  # resource errors. To customize the failure scenario, you can pass a
101
101
  # a block to <code>respond_with</code>:
@@ -202,10 +202,8 @@ module ActionController #:nodoc:
202
202
  display resource
203
203
  elsif post?
204
204
  display resource, :status => :created, :location => api_location
205
- elsif has_empty_resource_definition?
206
- display empty_resource, :status => :ok
207
205
  else
208
- head :ok
206
+ head :no_content
209
207
  end
210
208
  end
211
209
 
@@ -224,7 +222,7 @@ module ActionController #:nodoc:
224
222
  alias :navigation_location :resource_location
225
223
  alias :api_location :resource_location
226
224
 
227
- # If a given response block was given, use it, otherwise call render on
225
+ # If a response block was given, use it, otherwise call render on
228
226
  # controller.
229
227
  #
230
228
  def default_render
@@ -253,7 +251,7 @@ module ActionController #:nodoc:
253
251
  end
254
252
 
255
253
  def display_errors
256
- controller.render format => resource.errors, :status => :unprocessable_entity
254
+ controller.render format => resource_errors, :status => :unprocessable_entity
257
255
  end
258
256
 
259
257
  # Check whether the resource has errors.
@@ -269,22 +267,12 @@ module ActionController #:nodoc:
269
267
  @action ||= ACTIONS_FOR_VERBS[request.request_method_symbol]
270
268
  end
271
269
 
272
- # Check whether resource needs a specific definition of empty resource to be valid
273
- #
274
- def has_empty_resource_definition?
275
- respond_to?("empty_#{format}_resource", true)
270
+ def resource_errors
271
+ respond_to?("#{format}_resource_errors") ? send("#{format}_resource_errors") : resource.errors
276
272
  end
277
273
 
278
- # Delegate to proper empty resource method
279
- #
280
- def empty_resource
281
- send("empty_#{format}_resource")
282
- end
283
-
284
- # Return a valid empty JSON resource
285
- #
286
- def empty_json_resource
287
- "{}"
274
+ def json_resource_errors
275
+ {:errors => resource.errors}
288
276
  end
289
277
  end
290
278
  end
@@ -200,34 +200,9 @@ module ActionController #:nodoc:
200
200
  extend ActiveSupport::Concern
201
201
 
202
202
  include AbstractController::Rendering
203
- attr_internal :stream
204
-
205
- module ClassMethods
206
- # Render streaming templates. It accepts :only, :except, :if and :unless as options
207
- # to specify when to stream, as in ActionController filters.
208
- def stream(options={})
209
- ActiveSupport::Deprecation.warn "stream class method is deprecated. Please give the :stream option to render instead"
210
- if defined?(Fiber)
211
- before_filter :_stream_filter, options
212
- else
213
- raise "You cannot use streaming if Fiber is not available."
214
- end
215
- end
216
- end
217
203
 
218
204
  protected
219
205
 
220
- # Mark following render calls as streaming.
221
- def _stream_filter #:nodoc:
222
- self.stream = true
223
- end
224
-
225
- # Consider the stream option when normalazing options.
226
- def _normalize_options(options) #:nodoc:
227
- super
228
- options[:stream] = self.stream unless options.key?(:stream)
229
- end
230
-
231
206
  # Set proper cache control and transfer encoding when streaming
232
207
  def _process_options(options) #:nodoc:
233
208
  super
@@ -29,6 +29,7 @@ module ActionController
29
29
  # make sure readers methods get compiled
30
30
  options.asset_path ||= app.config.asset_path
31
31
  options.asset_host ||= app.config.asset_host
32
+ options.relative_url_root ||= app.config.relative_url_root
32
33
 
33
34
  ActiveSupport.on_load(:action_controller) do
34
35
  include app.routes.mounted_helpers