1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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

This commit is contained in:
Pratik Naik 2008-12-25 20:45:59 +00:00
parent 04a8b2362d
commit dd0753458f

View file

@ -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