diff options
author | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-12 16:21:34 -0700 |
---|---|---|
committer | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-12 16:21:34 -0700 |
commit | 216309c16519d94a9e0aebf758029a78696ab8d6 (patch) | |
tree | db271a9f9cb8ddf9aed72e125fe867d0e10d40e0 /actionpack/lib/action_controller/abstract/renderer.rb | |
parent | 72ca7c591c9eace150c0ebab1633d691a1ef12cf (diff) | |
download | rails-216309c16519d94a9e0aebf758029a78696ab8d6.tar.gz rails-216309c16519d94a9e0aebf758029a78696ab8d6.tar.bz2 rails-216309c16519d94a9e0aebf758029a78696ab8d6.zip |
Implemented redirects and partial rendering in new base.
Diffstat (limited to 'actionpack/lib/action_controller/abstract/renderer.rb')
-rw-r--r-- | actionpack/lib/action_controller/abstract/renderer.rb | 29 |
1 files changed, 13 insertions, 16 deletions
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 |