Rails 2.2.2

Updated to Rails 2.2.2.
Added a couple more Ruby 1.9 fixes, but that's pretty much at a standstill,
until one gets Maruku and HTML5lib working right under Ruby 1.9.
This commit is contained in:
Jacques Distler 2008-11-24 15:53:39 -06:00
parent 1b69b148de
commit 2e81ca2d30
716 changed files with 8009 additions and 113047 deletions

80
vendor/rails/actionpack/lib/action_controller/base.rb vendored Executable file → Normal file
View file

@ -278,12 +278,6 @@ module ActionController #:nodoc:
@@consider_all_requests_local = true
cattr_accessor :consider_all_requests_local
# Enable or disable the collection of failure information for RoutingErrors.
# This information can be extremely useful when tweaking custom routes, but is
# pointless once routes have been tested and verified.
@@debug_routes = true
cattr_accessor :debug_routes
# Indicates whether to allow concurrent action processing. Your
# controller actions and any other code they call must also behave well
# when called from concurrent threads. Turned off by default.
@ -364,11 +358,8 @@ module ActionController #:nodoc:
# If you are deploying to a subdirectory, you will need to set
# <tt>config.action_controller.relative_url_root</tt>
# This defaults to ENV['RAILS_RELATIVE_URL_ROOT']
cattr_writer :relative_url_root
def self.relative_url_root
@@relative_url_root || ENV['RAILS_RELATIVE_URL_ROOT']
end
cattr_accessor :relative_url_root
self.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT']
# Holds the request object that's primarily used to get environment variables through access like
# <tt>request.env["REQUEST_URI"]</tt>.
@ -801,6 +792,19 @@ module ActionController #:nodoc:
# # Renders "Hello from code!"
# render :text => proc { |response, output| output.write("Hello from code!") }
#
# === Rendering XML
#
# Rendering XML sets the content type to application/xml.
#
# # Renders '<name>David</name>'
# render :xml => {:name => "David"}.to_xml
#
# It's not necessary to call <tt>to_xml</tt> on the object you want to render, since <tt>render</tt> will
# automatically do that for you:
#
# # Also renders '<name>David</name>'
# render :xml => {:name => "David"}
#
# === Rendering JSON
#
# Rendering JSON sets the content type to application/json and optionally wraps the JSON in a callback. It is expected
@ -846,8 +850,14 @@ module ActionController #:nodoc:
# page.visual_effect :highlight, 'user_list'
# end
#
# === Rendering with status and location headers
# === Rendering vanilla JavaScript
#
# In addition to using RJS with render :update, you can also just render vanilla JavaScript with :js.
#
# # Renders "alert('hello')" and sets the mime type to text/javascript
# render :js => "alert('hello')"
#
# === Rendering with status and location headers
# All renders take the <tt>:status</tt> and <tt>:location</tt> options and turn them into headers. They can even be used together:
#
# render :xml => post.to_xml, :status => :created, :location => post_url(post)
@ -898,6 +908,10 @@ module ActionController #:nodoc:
response.content_type ||= Mime::XML
render_for_text(xml.respond_to?(:to_xml) ? xml.to_xml : xml, options[:status])
elsif js = options[:js]
response.content_type ||= Mime::JS
render_for_text(js, options[:status])
elsif json = options[:json]
json = json.to_json unless json.is_a?(String)
json = "#{options[:callback]}(#{json})" unless options[:callback].blank?
@ -933,6 +947,7 @@ module ActionController #:nodoc:
def render_to_string(options = nil, &block) #:doc:
render(options, &block)
ensure
response.content_type = nil
erase_render_results
reset_variables_added_to_assigns
end
@ -1014,10 +1029,10 @@ module ActionController #:nodoc:
#
# * <tt>Hash</tt> - The URL will be generated by calling url_for with the +options+.
# * <tt>Record</tt> - The URL will be generated by calling url_for with the +options+, which will reference a named URL for that record.
# * <tt>String starting with protocol:// (like http://)</tt> - Is passed straight through as the target for redirection.
# * <tt>String not containing a protocol</tt> - The current protocol and host is prepended to the string.
# * <tt>String</tt> starting with <tt>protocol://</tt> (like <tt>http://</tt>) - Is passed straight through as the target for redirection.
# * <tt>String</tt> not containing a protocol - The current protocol and host is prepended to the string.
# * <tt>:back</tt> - Back to the page that issued the request. Useful for forms that are triggered from multiple places.
# Short-hand for redirect_to(request.env["HTTP_REFERER"])
# Short-hand for <tt>redirect_to(request.env["HTTP_REFERER"])</tt>
#
# Examples:
# redirect_to :action => "show", :id => 5
@ -1049,11 +1064,14 @@ module ActionController #:nodoc:
status = 302
end
response.redirected_to= options
response.redirected_to = options
logger.info("Redirected to #{options}") if logger && logger.info?
case options
when %r{^\w+://.*}
# The scheme name consist of a letter followed by any combination of
# letters, digits, and the plus ("+"), period ("."), or hyphen ("-")
# characters; and is terminated by a colon (":").
when %r{^\w[\w\d+.-]*:.*}
redirect_to_full_url(options, status)
when String
redirect_to_full_url(request.protocol + request.host_with_port + options, status)
@ -1198,11 +1216,33 @@ module ActionController #:nodoc:
def log_processing
if logger && logger.info?
logger.info "\n\nProcessing #{self.class.name}\##{action_name} (for #{request_origin}) [#{request.method.to_s.upcase}]"
logger.info " Session ID: #{@_session.session_id}" if @_session and @_session.respond_to?(:session_id)
logger.info " Parameters: #{respond_to?(:filter_parameters) ? filter_parameters(params).inspect : params.inspect}"
log_processing_for_request_id
log_processing_for_session_id
log_processing_for_parameters
end
end
def log_processing_for_request_id
request_id = "\n\nProcessing #{self.class.name}\##{action_name} "
request_id << "to #{params[:format]} " if params[:format]
request_id << "(for #{request_origin}) [#{request.method.to_s.upcase}]"
logger.info(request_id)
end
def log_processing_for_session_id
if @_session && @_session.respond_to?(:session_id) && @_session.respond_to?(:dbman) &&
!@_session.dbman.is_a?(CGI::Session::CookieStore)
logger.info " Session ID: #{@_session.session_id}"
end
end
def log_processing_for_parameters
parameters = respond_to?(:filter_parameters) ? filter_parameters(params) : params.dup
parameters = parameters.except!(:controller, :action, :format, :_method)
logger.info " Parameters: #{parameters.inspect}" unless parameters.empty?
end
def default_render #:nodoc:
render