diff options
author | Prem Sichanugrist <s@sikachu.com> | 2012-03-05 21:06:02 -0500 |
---|---|---|
committer | Prem Sichanugrist <s@sikachu.com> | 2012-03-05 21:09:47 -0500 |
commit | 82a8698e564e5c27ac3516f0b44449a74b4389be (patch) | |
tree | 1176a476ced796af718c04382a45e3a219390a7b /actionpack/lib/action_controller/metal/responder.rb | |
parent | 5b73a3a5ca52043e67b448dc413aab9b8ccd1073 (diff) | |
download | rails-82a8698e564e5c27ac3516f0b44449a74b4389be.tar.gz rails-82a8698e564e5c27ac3516f0b44449a74b4389be.tar.bz2 rails-82a8698e564e5c27ac3516f0b44449a74b4389be.zip |
Always passing a respond block from to responder
We should let the responder to decide what to do with the given
overridden response block, and not short circuit it.
Fixes #5280
Diffstat (limited to 'actionpack/lib/action_controller/metal/responder.rb')
-rw-r--r-- | actionpack/lib/action_controller/metal/responder.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/metal/responder.rb b/actionpack/lib/action_controller/metal/responder.rb index daa1ddd65f..ad28abacb0 100644 --- a/actionpack/lib/action_controller/metal/responder.rb +++ b/actionpack/lib/action_controller/metal/responder.rb @@ -129,6 +129,7 @@ module ActionController #:nodoc: @resources = resources @options = options @action = options.delete(:action) + @default_response = options.delete(:default_response) end delegate :head, :render, :redirect_to, :to => :controller @@ -171,7 +172,7 @@ module ActionController #:nodoc: # responds to :to_format and display it. # def to_format - if get? || !has_errors? + if get? || !has_errors? || response_overridden? default_render else display_errors @@ -225,7 +226,11 @@ module ActionController #:nodoc: # controller. # def default_render - controller.default_render(options) + if @default_response + @default_response.call(options) + else + controller.default_render(options) + end end # Display is just a shortcut to render a resource with the current format. @@ -273,5 +278,9 @@ module ActionController #:nodoc: def json_resource_errors {:errors => resource.errors} end + + def response_overridden? + @default_response.present? + end end end |