aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2007-10-25 06:38:01 +0000
committerMichael Koziarski <michael@koziarski.com>2007-10-25 06:38:01 +0000
commit12d8d48b7132e0467b477e6a88931840188f6c61 (patch)
treeafa662a88e6428837d8dc9ef8746f0594ebf1abc /actionpack/lib
parent7c3581cba243aa17a9f002b40c5f017d8e968492 (diff)
downloadrails-12d8d48b7132e0467b477e6a88931840188f6c61.tar.gz
rails-12d8d48b7132e0467b477e6a88931840188f6c61.tar.bz2
rails-12d8d48b7132e0467b477e6a88931840188f6c61.zip
Refactor the default rendering out to a method called default_render to provide a hook for plugin authors. Closes #9953 [cjheath]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8011 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rwxr-xr-xactionpack/lib/action_controller/base.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index ed81cfc092..7ca2971236 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -70,7 +70,7 @@ module ActionController #:nodoc:
end
class DoubleRenderError < ActionControllerError #:nodoc:
- DEFAULT_MESSAGE = "Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and only 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\". Finally, note that to cause a before filter to halt execution of the rest of the filter chain, the filter must return false, explicitly, so \"render(...) and return false\"."
+ 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\". Finally, note that to cause a before filter to halt execution of the rest of the filter chain, the filter must return false, explicitly, so \"render(...) and return false\"."
def initialize(message = nil)
super(message || DEFAULT_MESSAGE)
@@ -226,7 +226,7 @@ module ActionController #:nodoc:
#
# == Calling multiple redirects or renders
#
- # An action should conclude with a single render or redirect. Attempting to try to do either again will result in a DoubleRenderError:
+ # An action may contain only a single render or a single redirect. Attempting to try to do either again will result in a DoubleRenderError:
#
# def do_something
# redirect_to :action => "elsewhere"
@@ -1125,15 +1125,19 @@ module ActionController #:nodoc:
end
end
+ def default_render #:nodoc:
+ render
+ end
+
def perform_action
if self.class.action_methods.include?(action_name)
send(action_name)
- render unless performed?
+ default_render unless performed?
elsif respond_to? :method_missing
method_missing action_name
- render unless performed?
+ default_render unless performed?
elsif template_exists? && template_public?
- render
+ default_render
else
raise UnknownAction, "No action responded to #{action_name}", caller
end