Permalink
Browse files

Move ActionController::Base#render arguments validation to a separate…

… method
  • Loading branch information...
lifo committed Dec 25, 2008
1 parent 04a8b23 commit dd0753458f2a16c876c52734f84a242f56746607
Showing with 14 additions and 8 deletions.
  1. +14 −8 actionpack/lib/action_controller/base.rb
@@ -859,16 +859,12 @@ def append_view_path(path)
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 @@ def render_for_text(text = nil, status = nil, append_response = false) #: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

0 comments on commit dd07534

Please sign in to comment.