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:
parent
04a8b2362d
commit
dd0753458f
1 changed files with 14 additions and 8 deletions
|
@ -859,16 +859,12 @@ module ActionController #:nodoc:
|
||||||
def render(options = nil, extra_options = {}, &block) #:doc:
|
def render(options = nil, extra_options = {}, &block) #:doc:
|
||||||
raise DoubleRenderError, "Can only render or redirect once per action" if performed?
|
raise DoubleRenderError, "Can only render or redirect once per action" if performed?
|
||||||
|
|
||||||
|
validate_render_arguments(options, extra_options)
|
||||||
|
|
||||||
if options.nil?
|
if options.nil?
|
||||||
return render(:file => default_template, :layout => true)
|
return render(:file => default_template, :layout => true)
|
||||||
elsif !extra_options.is_a?(Hash)
|
elsif options == :update
|
||||||
raise RenderError, "You called render with invalid options : #{options.inspect}, #{extra_options.inspect}"
|
|
||||||
else
|
|
||||||
if options == :update
|
|
||||||
options = extra_options.merge({ :update => true })
|
options = extra_options.merge({ :update => true })
|
||||||
elsif !options.is_a?(Hash)
|
|
||||||
raise RenderError, "You called render with invalid options : #{options.inspect}"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
layout = pick_layout(options)
|
layout = pick_layout(options)
|
||||||
|
@ -1186,6 +1182,16 @@ module ActionController #:nodoc:
|
||||||
end
|
end
|
||||||
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)
|
def initialize_template_class(response)
|
||||||
response.template = ActionView::Base.new(self.class.view_paths, {}, self)
|
response.template = ActionView::Base.new(self.class.view_paths, {}, self)
|
||||||
response.template.helpers.send :include, self.class.master_helper_module
|
response.template.helpers.send :include, self.class.master_helper_module
|
||||||
|
|
Loading…
Reference in a new issue