Rails 2.1
Update to Rails 2.1 final.
This commit is contained in:
parent
fd554cce90
commit
516d6dfac0
257 changed files with 4058 additions and 1933 deletions
|
@ -104,7 +104,7 @@ module ActionController #:nodoc:
|
|||
# end
|
||||
#
|
||||
# Actions, by default, render a template in the <tt>app/views</tt> directory corresponding to the name of the controller and action
|
||||
# after executing code in the action. For example, the +index+ action of the +GuestBookController+ would render the
|
||||
# after executing code in the action. For example, the +index+ action of the GuestBookController would render the
|
||||
# template <tt>app/views/guestbook/index.erb</tt> by default after populating the <tt>@entries</tt> instance variable.
|
||||
#
|
||||
# Unlike index, the sign action will not render a template. After performing its main purpose (creating a
|
||||
|
@ -118,10 +118,10 @@ module ActionController #:nodoc:
|
|||
#
|
||||
# Requests are processed by the Action Controller framework by extracting the value of the "action" key in the request parameters.
|
||||
# This value should hold the name of the action to be performed. Once the action has been identified, the remaining
|
||||
# request parameters, the session (if one is available), and the full request with all the http headers are made available to
|
||||
# request parameters, the session (if one is available), and the full request with all the HTTP headers are made available to
|
||||
# the action through instance variables. Then the action is performed.
|
||||
#
|
||||
# The full request object is available with the request accessor and is primarily used to query for http headers. These queries
|
||||
# The full request object is available with the request accessor and is primarily used to query for HTTP headers. These queries
|
||||
# are made by accessing the environment hash, like this:
|
||||
#
|
||||
# def server_ip
|
||||
|
@ -259,12 +259,12 @@ module ActionController #:nodoc:
|
|||
DEFAULT_RENDER_STATUS_CODE = "200 OK"
|
||||
|
||||
include StatusCodes
|
||||
|
||||
|
||||
# Controller specific instance variables which will not be accessible inside views.
|
||||
@@protected_view_variables = %w(@assigns @performed_redirect @performed_render @variables_added @request_origin @url @parent_controller
|
||||
@action_name @before_filter_chain_aborted @action_cache_path @_session @_cookies @_headers @_params
|
||||
@_flash @_response)
|
||||
|
||||
|
||||
# Prepends all the URL-generating helpers from AssetHelper. This makes it possible to easily move javascripts, stylesheets,
|
||||
# and images to a dedicated asset server away from the main web server. Example:
|
||||
# ActionController::Base.asset_host = "http://assets.example.com"
|
||||
|
@ -291,10 +291,10 @@ module ActionController #:nodoc:
|
|||
cattr_accessor :allow_concurrency
|
||||
|
||||
# Modern REST web services often need to submit complex data to the web application.
|
||||
# The param_parsers hash lets you register handlers which will process the http body and add parameters to the
|
||||
# <tt>params</tt> hash. These handlers are invoked for post and put requests.
|
||||
# The <tt>@@param_parsers</tt> hash lets you register handlers which will process the HTTP body and add parameters to the
|
||||
# <tt>params</tt> hash. These handlers are invoked for POST and PUT requests.
|
||||
#
|
||||
# By default application/xml is enabled. A XmlSimple class with the same param name as the root will be instantiated
|
||||
# By default <tt>application/xml</tt> is enabled. A XmlSimple class with the same param name as the root will be instantiated
|
||||
# in the <tt>params</tt>. This allows XML requests to mask themselves as regular form submissions, so you can have one
|
||||
# action serve both regular forms and web service requests.
|
||||
#
|
||||
|
@ -307,7 +307,7 @@ module ActionController #:nodoc:
|
|||
#
|
||||
# Note: Up until release 1.1 of Rails, Action Controller would default to using XmlSimple configured to discard the
|
||||
# root node for such requests. The new default is to keep the root, such that "<r><name>David</name></r>" results
|
||||
# in params[:r][:name] for "David" instead of params[:name]. To get the old behavior, you can
|
||||
# in <tt>params[:r][:name]</tt> for "David" instead of <tt>params[:name]</tt>. To get the old behavior, you can
|
||||
# re-register XmlSimple as application/xml handler ike this:
|
||||
#
|
||||
# ActionController::Base.param_parsers[Mime::XML] =
|
||||
|
@ -325,7 +325,7 @@ module ActionController #:nodoc:
|
|||
# Controls the default charset for all renders.
|
||||
@@default_charset = "utf-8"
|
||||
cattr_accessor :default_charset
|
||||
|
||||
|
||||
# The logger is used for generating information on the action run-time (including benchmarking) if available.
|
||||
# Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers.
|
||||
cattr_accessor :logger
|
||||
|
@ -333,7 +333,7 @@ module ActionController #:nodoc:
|
|||
# Controls the resource action separator
|
||||
@@resource_action_separator = "/"
|
||||
cattr_accessor :resource_action_separator
|
||||
|
||||
|
||||
# Allow to override path names for default resources' actions
|
||||
@@resources_path_names = { :new => 'new', :edit => 'edit' }
|
||||
cattr_accessor :resources_path_names
|
||||
|
@ -433,7 +433,7 @@ module ActionController #:nodoc:
|
|||
end
|
||||
|
||||
# Adds a view_path to the front of the view_paths array.
|
||||
# If the current class has no view paths, copy them from
|
||||
# If the current class has no view paths, copy them from
|
||||
# the superclass. This change will be visible for all future requests.
|
||||
#
|
||||
# ArticleController.prepend_view_path("views/default")
|
||||
|
@ -444,9 +444,9 @@ module ActionController #:nodoc:
|
|||
view_paths.unshift(*path)
|
||||
ActionView::TemplateFinder.process_view_paths(path)
|
||||
end
|
||||
|
||||
|
||||
# Adds a view_path to the end of the view_paths array.
|
||||
# If the current class has no view paths, copy them from
|
||||
# If the current class has no view paths, copy them from
|
||||
# the superclass. This change will be visible for all future requests.
|
||||
#
|
||||
# ArticleController.append_view_path("views/default")
|
||||
|
@ -457,7 +457,7 @@ module ActionController #:nodoc:
|
|||
view_paths.push(*path)
|
||||
ActionView::TemplateFinder.process_view_paths(path)
|
||||
end
|
||||
|
||||
|
||||
# Replace sensitive parameter data from the request log.
|
||||
# Filters parameters that have any of the arguments as a substring.
|
||||
# Looks in all subhashes of the param hash for keys to filter.
|
||||
|
@ -504,6 +504,7 @@ module ActionController #:nodoc:
|
|||
|
||||
filtered_parameters
|
||||
end
|
||||
protected :filter_parameters
|
||||
end
|
||||
|
||||
# Don't render layouts for templates with the given extensions.
|
||||
|
@ -643,12 +644,12 @@ module ActionController #:nodoc:
|
|||
end
|
||||
|
||||
self.view_paths = []
|
||||
|
||||
|
||||
# View load paths for controller.
|
||||
def view_paths
|
||||
@template.finder.view_paths
|
||||
end
|
||||
|
||||
|
||||
def view_paths=(value)
|
||||
@template.finder.view_paths = value # Mutex needed
|
||||
end
|
||||
|
@ -662,7 +663,7 @@ module ActionController #:nodoc:
|
|||
def prepend_view_path(path)
|
||||
@template.finder.prepend_view_path(path) # Mutex needed
|
||||
end
|
||||
|
||||
|
||||
# Adds a view_path to the end of the view_paths array.
|
||||
# This change affects the current request only.
|
||||
#
|
||||
|
@ -874,10 +875,10 @@ module ActionController #:nodoc:
|
|||
elsif action_name = options[:action]
|
||||
template = default_template_name(action_name.to_s)
|
||||
if options[:layout] && !template_exempt_from_layout?(template)
|
||||
render_with_a_layout(:file => template, :status => options[:status], :use_full_path => true, :layout => true)
|
||||
render_with_a_layout(:file => template, :status => options[:status], :use_full_path => true, :layout => true)
|
||||
else
|
||||
render_with_no_layout(:file => template, :status => options[:status], :use_full_path => true)
|
||||
end
|
||||
end
|
||||
|
||||
elsif xml = options[:xml]
|
||||
response.content_type ||= Mime::XML
|
||||
|
@ -895,12 +896,12 @@ module ActionController #:nodoc:
|
|||
|
||||
if collection = options[:collection]
|
||||
render_for_text(
|
||||
@template.send!(:render_partial_collection, partial, collection,
|
||||
@template.send!(:render_partial_collection, partial, collection,
|
||||
options[:spacer_template], options[:locals]), options[:status]
|
||||
)
|
||||
else
|
||||
render_for_text(
|
||||
@template.send!(:render_partial, partial,
|
||||
@template.send!(:render_partial, partial,
|
||||
ActionView::Base::ObjectWrapper.new(options[:object]), options[:locals]), options[:status]
|
||||
)
|
||||
end
|
||||
|
@ -1024,7 +1025,7 @@ module ActionController #:nodoc:
|
|||
# redirect_to articles_url
|
||||
# redirect_to :back
|
||||
#
|
||||
# The redirection happens as a "302 Moved" header unless otherwise specified.
|
||||
# The redirection happens as a "302 Moved" header unless otherwise specified.
|
||||
#
|
||||
# Examples:
|
||||
# redirect_to post_url(@post), :status=>:found
|
||||
|
@ -1035,17 +1036,17 @@ module ActionController #:nodoc:
|
|||
# When using <tt>redirect_to :back</tt>, if there is no referrer,
|
||||
# RedirectBackError will be raised. You may specify some fallback
|
||||
# behavior for this case by rescuing RedirectBackError.
|
||||
def redirect_to(options = {}, response_status = {}) #:doc:
|
||||
def redirect_to(options = {}, response_status = {}) #:doc:
|
||||
raise ActionControllerError.new("Cannot redirect to nil!") if options.nil?
|
||||
|
||||
if options.is_a?(Hash) && options[:status]
|
||||
status = options.delete(:status)
|
||||
elsif response_status[:status]
|
||||
status = response_status[:status]
|
||||
else
|
||||
status = 302
|
||||
if options.is_a?(Hash) && options[:status]
|
||||
status = options.delete(:status)
|
||||
elsif response_status[:status]
|
||||
status = response_status[:status]
|
||||
else
|
||||
status = 302
|
||||
end
|
||||
|
||||
|
||||
case options
|
||||
when %r{^\w+://.*}
|
||||
raise DoubleRenderError if performed?
|
||||
|
@ -1119,7 +1120,7 @@ module ActionController #:nodoc:
|
|||
response.body = text.is_a?(Proc) ? text : text.to_s
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def initialize_template_class(response)
|
||||
response.template = ActionView::Base.new(self.class.view_paths, {}, self)
|
||||
response.template.extend self.class.master_helper_module
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue