From 53596d091390bda7fb9b78ad838273a9e63fbde1 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sun, 15 Jan 2012 15:37:27 -0200 Subject: Refactor render nothing/text => nil logic, and move to right place Options :nothing and :text => nil should be handled by ActionController::Rendering instead. --- actionpack/lib/action_controller/metal/rendering.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'actionpack/lib/action_controller/metal/rendering.rb') diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb index 70fd79bb8b..f6e9e4c4ac 100644 --- a/actionpack/lib/action_controller/metal/rendering.rb +++ b/actionpack/lib/action_controller/metal/rendering.rb @@ -44,6 +44,10 @@ module ActionController options[:text] = options[:text].to_text end + if options.delete(:nothing) || (options.key?(:text) && options[:text].nil?) + options[:text] = " " + end + if options[:status] options[:status] = Rack::Utils.status_code(options[:status]) end -- cgit v1.2.3 From 67c96ab024f008ad1aee8345c1ae0fd7aa9bf072 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sun, 15 Jan 2012 22:07:20 -0200 Subject: Move render_to_body logic to return a spaced string to AC::Rendering This seems to be required only when calling render :partial with an empty collection from a controller. This call happens to return no content, letting the response body empty, which means to Rails that it should go on and try to find a template to render based on the current action name, thus failing hard. Although tests keep all green, we need to check a better way to fix this. --- actionpack/lib/action_controller/metal/rendering.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'actionpack/lib/action_controller/metal/rendering.rb') diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb index f6e9e4c4ac..a677cdf15d 100644 --- a/actionpack/lib/action_controller/metal/rendering.rb +++ b/actionpack/lib/action_controller/metal/rendering.rb @@ -29,6 +29,10 @@ module ActionController self.response_body = nil end + def render_to_body(*) + super || " " + end + private # Normalize arguments by catching blocks and setting them on :update. -- cgit v1.2.3