Added DoubleRenderError exception that'll be raised if render* is called twice #518 [Nicholas Seckar]. Fixed exceptions occuring after render has been called #1096 [Nicholas Seckar]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1348 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
3022ee84cc
commit
dab360e181
@ -24,6 +24,8 @@ class UnknownAction < ActionControllerError #:nodoc:
|
||||
end
|
||||
class MissingFile < ActionControllerError #:nodoc:
|
||||
end
|
||||
class DoubleRenderError < ActionControllerError #:nodoc:
|
||||
end
|
||||
|
||||
# Action Controllers are made up of one or more actions that performs its purpose and then either renders a template or
|
||||
# redirects to another action. An action is defined as a public method on the controller, which will automatically be
|
||||
@ -476,7 +478,7 @@ def render_template(template, status = nil, type = "rhtml") #:doc:
|
||||
# considerably faster than rendering through the template engine.
|
||||
# Use block for response body if provided (useful for deferred rendering or streaming output).
|
||||
def render_text(text = nil, status = nil, &block) #:doc:
|
||||
return if performed?
|
||||
raise DoubleRenderError, "Can only render or redirect once per action" if performed?
|
||||
add_variables_to_assigns
|
||||
@response.headers["Status"] = status.to_s || DEFAULT_RENDER_STATUS_CODE
|
||||
@response.body = block_given? ? block : text
|
||||
@ -495,6 +497,12 @@ def render_to_string(template_name = default_template_name) #:doc:
|
||||
@template.render_file(template_name)
|
||||
end
|
||||
|
||||
# Clears the rendered results, allowing for another render or redirect to be performed.
|
||||
def erase_render_results #:nodoc:
|
||||
@response.body = nil
|
||||
@performed_render = false
|
||||
end
|
||||
|
||||
# Renders the partial specified by <tt>partial_path</tt>, which by default is the name of the action itself. Example:
|
||||
#
|
||||
# class WeblogController < ActionController::Base
|
||||
@ -659,7 +667,7 @@ def redirect_to_path(path) #:doc:
|
||||
# <tt>redirect_to_url "http://www.rubyonrails.org"</tt>. If the resource has moved permanently, it's possible to pass true as the
|
||||
# second parameter and the browser will get "301 Moved Permanently" instead of "302 Found".
|
||||
def redirect_to_url(url, permanently = false) #:doc:
|
||||
return if performed?
|
||||
raise DoubleRenderError, "Can only render or redirect once per action" if performed?
|
||||
logger.info("Redirected to #{url}") unless logger.nil?
|
||||
@response.redirect(url, permanently)
|
||||
@performed_redirect = true
|
||||
|
@ -25,6 +25,7 @@ def process_with_exception(request, response, exception)
|
||||
# Exception handler called when the performance of an action raises an exception.
|
||||
def rescue_action(exception)
|
||||
log_error(exception) unless logger.nil?
|
||||
erase_render_results if performed?
|
||||
|
||||
if consider_all_requests_local || local_request?
|
||||
rescue_action_locally(exception)
|
||||
|
@ -1,5 +1,9 @@
|
||||
*SVN*
|
||||
|
||||
* Added DoubleRenderError exception that'll be raised if render* is called twice #518 [Nicholas Seckar]
|
||||
|
||||
* Fixed exceptions occuring after render has been called #1096 [Nicholas Seckar]
|
||||
|
||||
* CHANGED: validates_presence_of now uses Errors#add_on_blank, which will make " " fail the validation where it didn't before #1309
|
||||
|
||||
* Added Errors#add_on_blank which works like Errors#add_on_empty, but uses Object#blank? instead
|
||||
|
Loading…
Reference in New Issue
Block a user