From dd0753458f2a16c876c52734f84a242f56746607 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Thu, 25 Dec 2008 20:45:59 +0000 Subject: Move ActionController::Base#render arguments validation to a separate method --- actionpack/lib/action_controller/base.rb | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 4d4793c4e3..552075025f 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -859,16 +859,12 @@ module ActionController #:nodoc: def render(options = nil, extra_options = {}, &block) #:doc: raise DoubleRenderError, "Can only render or redirect once per action" if performed? + validate_render_arguments(options, extra_options) + if options.nil? return render(:file => default_template, :layout => true) - elsif !extra_options.is_a?(Hash) - raise RenderError, "You called render with invalid options : #{options.inspect}, #{extra_options.inspect}" - else - if options == :update - options = extra_options.merge({ :update => true }) - elsif !options.is_a?(Hash) - raise RenderError, "You called render with invalid options : #{options.inspect}" - end + elsif options == :update + options = extra_options.merge({ :update => true }) end layout = pick_layout(options) @@ -1186,6 +1182,16 @@ module ActionController #:nodoc: end end + def validate_render_arguments(options, extra_options) + if options && options != :update && !options.is_a?(Hash) + raise RenderError, "You called render with invalid options : #{options.inspect}" + end + + if !extra_options.is_a?(Hash) + raise RenderError, "You called render with invalid options : #{options.inspect}, #{extra_options.inspect}" + end + end + def initialize_template_class(response) response.template = ActionView::Base.new(self.class.view_paths, {}, self) response.template.helpers.send :include, self.class.master_helper_module -- cgit v1.2.3