From 576b1627254ff0d40063312d7df876706a87eba6 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 10 Jan 2005 01:27:39 +0000 Subject: Added that all renders and redirects now return false, so they can be used as the last line in before_filters to stop execution. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@364 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 15 +++++++++++++++ actionpack/lib/action_controller/base.rb | 2 ++ 2 files changed, 17 insertions(+) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 911ffd4340..d43ada01f0 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,20 @@ *SVN* +* Added that all renders and redirects now return false, so they can be used as the last line in before_filters to stop execution. + + Before: + def authenticate + unless @session[:authenticated] + redirect_to :controller => "account", :action => "login" + return false + end + end + + After: + def authenticate + redirect_to(:controller => "account", :action => "login") unless @session[:authenticated] + end + * Added conditional filters #431 [Marcel]. Example: class JournalController < ActionController::Base diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index dbdce1bbfd..33e3014ee9 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -389,6 +389,7 @@ module ActionController #:nodoc: @response.headers["Status"] = status || DEFAULT_RENDER_STATUS_CODE @response.body = block_given? ? block : text @performed_render = true + return false end # Renders an empty response that can be used when the request is only interested in triggering an effect. Do note that good @@ -543,6 +544,7 @@ module ActionController #:nodoc: logger.info("Redirected to #{url}") unless logger.nil? @response.redirect(url, permanently) @performed_redirect = true + return false end # Resets the session by clearsing out all the objects stored within and initializing a new session object. -- cgit v1.2.3