aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/abstract
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/abstract')
-rw-r--r--actionpack/lib/action_controller/abstract/base.rb10
-rw-r--r--actionpack/lib/action_controller/abstract/layouts.rb2
-rw-r--r--actionpack/lib/action_controller/abstract/renderer.rb29
3 files changed, 24 insertions, 17 deletions
diff --git a/actionpack/lib/action_controller/abstract/base.rb b/actionpack/lib/action_controller/abstract/base.rb
index ab9aed0b26..c9e1081b23 100644
--- a/actionpack/lib/action_controller/abstract/base.rb
+++ b/actionpack/lib/action_controller/abstract/base.rb
@@ -1,4 +1,14 @@
module AbstractController
+ class Error < StandardError; end
+
+ class DoubleRenderError < Error
+ DEFAULT_MESSAGE = "Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like \"redirect_to(...) and return\"."
+
+ def initialize(message = nil)
+ super(message || DEFAULT_MESSAGE)
+ end
+ end
+
class Base
attr_internal :response_body
diff --git a/actionpack/lib/action_controller/abstract/layouts.rb b/actionpack/lib/action_controller/abstract/layouts.rb
index e48b8b2b4b..35d5e85ed9 100644
--- a/actionpack/lib/action_controller/abstract/layouts.rb
+++ b/actionpack/lib/action_controller/abstract/layouts.rb
@@ -51,7 +51,7 @@ module AbstractController
end
def _render_template(template, options)
- _action_view._render_template_with_layout(template, options[:_layout], options)
+ _action_view._render_template_from_controller(template, options[:_layout], options, options[:_partial])
end
private
diff --git a/actionpack/lib/action_controller/abstract/renderer.rb b/actionpack/lib/action_controller/abstract/renderer.rb
index b58688c9da..f2044a35ec 100644
--- a/actionpack/lib/action_controller/abstract/renderer.rb
+++ b/actionpack/lib/action_controller/abstract/renderer.rb
@@ -1,15 +1,6 @@
require "action_controller/abstract/logger"
module AbstractController
- class AbstractControllerError < StandardError; end
- class DoubleRenderError < AbstractControllerError
- DEFAULT_MESSAGE = "Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like \"redirect_to(...) and return\"."
-
- def initialize(message = nil)
- super(message || DEFAULT_MESSAGE)
- end
- end
-
module Renderer
extend ActiveSupport::DependencyModule
@@ -27,12 +18,12 @@ module AbstractController
@_action_view ||= ActionView::Base.new(self.class.view_paths, {}, self)
end
- def render(options = {})
+ def render(*args)
if response_body
raise AbstractController::DoubleRenderError, "OMG"
end
- self.response_body = render_to_body(options)
+ self.response_body = render_to_body(*args)
end
# Raw rendering of a template to a Rack-compatible body.
@@ -43,10 +34,16 @@ module AbstractController
# :api: plugin
def render_to_body(options = {})
name = options[:_template_name] || action_name
-
- options[:_template] ||= view_paths.find_by_parts(name.to_s, {:formats => formats}, options[:_prefix])
-
- _render_template(options[:_template], options)
+
+ # TODO: Refactor so we can just use the normal template logic for this
+ if options[:_partial_object]
+ _action_view._render_partial_from_controller(options)
+ else
+ options[:_template] ||= view_paths.find_by_parts(name.to_s, {:formats => formats},
+ options[:_prefix], options[:_partial])
+
+ _render_template(options[:_template], options)
+ end
end
# Raw rendering of a template to a string.
@@ -60,7 +57,7 @@ module AbstractController
end
def _render_template(template, options)
- _action_view._render_template_with_layout(template)
+ _action_view._render_template_from_controller(template, nil, options, options[:_partial])
end
def view_paths() _view_paths end