diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-12-25 20:45:59 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-12-25 20:49:31 +0000 |
commit | dd0753458f2a16c876c52734f84a242f56746607 (patch) | |
tree | 7e1a57a9161aca9abf382023cad4796c53e48d4e /actionpack/lib | |
parent | 04a8b2362deb37f33c0a9060510f194286b6822a (diff) | |
download | rails-dd0753458f2a16c876c52734f84a242f56746607.tar.gz rails-dd0753458f2a16c876c52734f84a242f56746607.tar.bz2 rails-dd0753458f2a16c876c52734f84a242f56746607.zip |
Move ActionController::Base#render arguments validation to a separate method
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/base.rb | 22 |
1 files changed, 14 insertions, 8 deletions
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 |