Including UrlFor in Redirecting and Head will warn usefully if a controller is wired up without a router included (and still support redirect_to "omg")

This commit is contained in:
Carlhuda 2010-02-26 15:56:17 -08:00
parent 3bad24c85d
commit dae109a463
2 changed files with 3 additions and 6 deletions

View File

@ -2,6 +2,8 @@ module ActionController
module Head
extend ActiveSupport::Concern
include ActionController::UrlFor
# Return a response that has no content (merely headers). The options
# argument is interpreted to be a hash of header names and values.
# This allows you to easily return a response that consists only of
@ -24,9 +26,6 @@ module ActionController
end
self.status = status
# ROUTES TODO: Figure out how to rescue from a no method error
# This is needed only if you wire up a controller yourself, and
# this not working would be baffling without a better error
self.location = url_for(location) if location
self.content_type = Mime[formats.first]
self.response_body = " "

View File

@ -12,6 +12,7 @@ module ActionController
include AbstractController::Logger
include ActionController::RackDelegation
include ActionController::UrlFor
# Redirects the browser to the target specified in +options+. This parameter can take one of three forms:
#
@ -83,9 +84,6 @@ module ActionController
raise RedirectBackError unless refer = request.headers["Referer"]
refer
else
# ROUTES TODO: Figure out how to rescue from a no method error
# This is needed only if you wire up a controller yourself, and
# this not working would be baffling without a better error
url_for(options)
end.gsub(/[\r\n]/, '')
end