Permalink
Browse files

Merge remote branch 'origin/master'

  • Loading branch information...
bryanwoods committed Jun 16, 2010
2 parents c1ff781 + 35e3f72 commit 5861fde01fbe9446666b319dfc8d24514aafda21
Showing with 238 additions and 108 deletions.
  1. +6 −4 actionpack/lib/action_view/base.rb
  2. +9 −12 actionpack/lib/action_view/context.rb
  3. +1 −0 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  4. +4 −2 actionpack/lib/action_view/helpers/atom_feed_helper.rb
  5. +4 −2 actionpack/lib/action_view/helpers/cache_helper.rb
  6. +2 −0 actionpack/lib/action_view/helpers/capture_helper.rb
  7. +3 −1 actionpack/lib/action_view/helpers/csrf_helper.rb
  8. +2 −0 actionpack/lib/action_view/helpers/date_helper.rb
  9. +3 −1 actionpack/lib/action_view/helpers/debug_helper.rb
  10. +1 −0 actionpack/lib/action_view/helpers/form_helper.rb
  11. +1 −0 actionpack/lib/action_view/helpers/form_options_helper.rb
  12. +1 −0 actionpack/lib/action_view/helpers/form_tag_helper.rb
  13. +1 −0 actionpack/lib/action_view/helpers/javascript_helper.rb
  14. +1 −0 actionpack/lib/action_view/helpers/prototype_helper.rb
  15. +9 −0 actionpack/lib/action_view/helpers/raw_output_helper.rb
  16. +1 −0 actionpack/lib/action_view/helpers/record_tag_helper.rb
  17. +11 −5 actionpack/lib/action_view/helpers/sanitize_helper.rb
  18. +5 −2 actionpack/lib/action_view/helpers/scriptaculous_helper.rb
  19. +1 −0 actionpack/lib/action_view/helpers/tag_helper.rb
  20. +1 −0 actionpack/lib/action_view/helpers/text_helper.rb
  21. +17 −10 actionpack/lib/action_view/helpers/translation_helper.rb
  22. +1 −0 actionpack/lib/action_view/helpers/url_helper.rb
  23. +2 −0 actionpack/lib/action_view/lookup_context.rb
  24. +1 −0 actionpack/lib/action_view/paths.rb
  25. +1 −0 actionpack/lib/action_view/railtie.rb
  26. +1 −0 actionpack/lib/action_view/render/layouts.rb
  27. +2 −0 actionpack/lib/action_view/render/partials.rb
  28. +1 −0 actionpack/lib/action_view/render/rendering.rb
  29. +1 −0 actionpack/lib/action_view/template.rb
  30. +2 −0 activerecord/lib/active_record/associations/association_collection.rb
  31. +2 −0 activerecord/lib/active_record/associations/association_proxy.rb
  32. +1 −0 activerecord/lib/active_record/associations/belongs_to_association.rb
  33. +1 −0 activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb
  34. +1 −0 activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
  35. +1 −0 activerecord/lib/active_record/associations/has_many_association.rb
  36. +1 −0 activerecord/lib/active_record/associations/has_many_through_association.rb
  37. +1 −0 activerecord/lib/active_record/associations/has_one_association.rb
  38. +1 −0 activerecord/lib/active_record/associations/has_one_through_association.rb
  39. +1 −0 activerecord/lib/active_record/associations/through_association_scope.rb
  40. +1 −1 activerecord/lib/active_record/migration.rb
  41. +7 −4 activerecord/lib/active_record/named_scope.rb
  42. +2 −1 activerecord/lib/active_record/nested_attributes.rb
  43. +2 −0 activerecord/lib/active_record/observer.rb
  44. +18 −11 activerecord/lib/active_record/persistence.rb
  45. +1 −0 activerecord/lib/active_record/query_cache.rb
  46. +1 −0 activerecord/lib/active_record/railtie.rb
  47. +30 −15 activerecord/lib/active_record/reflection.rb
  48. +6 −2 activerecord/lib/active_record/relation.rb
  49. +2 −0 activerecord/lib/active_record/schema.rb
  50. +9 −6 activerecord/lib/active_record/schema_dumper.rb
  51. +2 −0 activerecord/lib/active_record/serialization.rb
  52. +8 −0 activerecord/lib/active_record/session_store.rb
  53. +3 −0 activerecord/lib/active_record/test_case.rb
  54. +12 −6 activerecord/lib/active_record/timestamp.rb
  55. +4 −2 activerecord/lib/active_record/transactions.rb
  56. +3 −0 activerecord/lib/active_record/validations.rb
  57. +2 −2 railties/guides/source/active_record_querying.textile
  58. +19 −19 railties/guides/source/active_support_core_extensions.textile
@@ -8,11 +8,13 @@ module ActionView #:nodoc:
class NonConcattingString < ActiveSupport::SafeBuffer
end
+ # = Action View Base
+ #
# Action View templates can be written in three ways. If the template file has a <tt>.erb</tt> (or <tt>.rhtml</tt>) extension then it uses a mixture of ERb
# (included in Ruby) and HTML. If the template file has a <tt>.builder</tt> (or <tt>.rxml</tt>) extension then Jim Weirich's Builder::XmlMarkup library is used.
# If the template file has a <tt>.rjs</tt> extension then it will use ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.
#
- # = ERb
+ # == ERb
#
# You trigger ERb by using embeddings such as <% %>, <% -%>, and <%= %>. The <%= %> tag set is used when you want output. Consider the
# following loop for names:
@@ -32,7 +34,7 @@ class NonConcattingString < ActiveSupport::SafeBuffer
#
# <%- and -%> suppress leading and trailing whitespace, including the trailing newline, and can be used interchangeably with <% and %>.
#
- # == Using sub templates
+ # === Using sub templates
#
# Using sub templates allows you to sidestep tedious replication and extract common display structures in shared templates. The
# classic example is the use of a header and footer (even though the Action Pack-way would be to use Layouts):
@@ -54,7 +56,7 @@ class NonConcattingString < ActiveSupport::SafeBuffer
#
# <title><%= @page_title %></title>
#
- # == Passing local variables to sub templates
+ # === Passing local variables to sub templates
#
# You can pass local variables to sub templates by using a hash with the variable names as keys and the objects as values:
#
@@ -74,7 +76,7 @@ class NonConcattingString < ActiveSupport::SafeBuffer
#
# Testing using <tt>defined? headline</tt> will not work. This is an implementation restriction.
#
- # == Template caching
+ # === Template caching
#
# By default, Rails will compile each template to a method in order to render it. When you alter a template, Rails will
# check the file's modification time and recompile it.
@@ -2,13 +2,12 @@ module ActionView
module CompiledTemplates #:nodoc:
# holds compiled template code
end
-
- # Action View contexts are supplied to Action Controller
- # to render template. The default Action View context
- # is ActionView::Base.
+ # = Action View Context
+ #
+ # Action View contexts are supplied to Action Controller to render template.
+ # The default Action View context is ActionView::Base.
#
- # In order to work with ActionController, a Context
- # must implement:
+ # In order to work with ActionController, a Context must implement:
#
# Context#render_partial[options]
# - responsible for setting options[:_template]
@@ -21,16 +20,14 @@ module CompiledTemplates #:nodoc:
# options<Hash>:: See _render_template_with_layout in ActionView::Base
# partial<Boolean>:: Whether or not the template to render is a partial
#
- # An Action View context can also mix in Action View's
- # helpers. In order to mix in helpers, a context must
- # implement:
+ # An Action View context can also mix in Action View's helpers. In order to
+ # mix in helpers, a context must implement:
#
# Context#controller
# - Returns an instance of AbstractController
#
- # In any case, a context must mix in ActionView::Context,
- # which stores compiled template and provides the output
- # buffer.
+ # In any case, a context must mix in ActionView::Context, which stores compiled
+ # template and provides the output buffer.
module Context
include CompiledTemplates
attr_accessor :output_buffer
@@ -6,6 +6,7 @@
require 'active_support/core_ext/object/blank'
module ActionView
+ # = Action View Asset Tag Helpers
module Helpers #:nodoc:
# This module provides methods for generating HTML that links views to assets such
# as images, javascripts, stylesheets, and feeds. These methods do not verify
@@ -1,10 +1,12 @@
require 'set'
-# Adds easy defaults to writing Atom feeds with the Builder template engine (this does not work on ERb or any other
-# template languages).
module ActionView
+ # = Action View Atom Feed Helpers
module Helpers #:nodoc:
module AtomFeedHelper
+ # Adds easy defaults to writing Atom feeds with the Builder template engine (this does not work on ERb or any other
+ # template languages).
+ #
# Full usage example:
#
# config/routes.rb:
@@ -1,8 +1,10 @@
module ActionView
+ # = Action View Cache Helper
module Helpers
- # This helper to exposes a method for caching of view fragments.
- # See ActionController::Caching::Fragments for usage instructions.
module CacheHelper
+ # This helper to exposes a method for caching of view fragments.
+ # See ActionController::Caching::Fragments for usage instructions.
+ #
# A method for caching fragments of a view rather than an entire
# action or page. This technique is useful caching pieces like
# menus, lists of news topics, static HTML fragments, and so on.
@@ -1,9 +1,11 @@
require 'active_support/core_ext/object/blank'
module ActionView
+ # = Action View Capture Helper
module Helpers
# CaptureHelper exposes methods to let you extract generated markup which
# can be used in other parts of a template or layout file.
+ #
# It provides a method to capture blocks into variables through capture and
# a way to capture a block of markup for use in a layout through content_for.
module CaptureHelper
@@ -1,7 +1,9 @@
module ActionView
+ # = Action View CSRF Helper
module Helpers
module CsrfHelper
- # Returns a meta tag with the request forgery protection token for forms to use. Put this in your head.
+ # Returns a meta tag with the cross-site request forgery protection token
+ # for forms to use. Place this in your head.
def csrf_meta_tag
if protect_against_forgery?
%(<meta name="csrf-param" content="#{Rack::Utils.escape_html(request_forgery_protection_token)}"/>\n<meta name="csrf-token" content="#{Rack::Utils.escape_html(form_authenticity_token)}"/>).html_safe
@@ -4,6 +4,8 @@
module ActionView
module Helpers
+ # = Action View Date Helpers
+ #
# The Date Helper primarily creates select/option tags for different kinds of dates and date elements. All of the
# select-type methods share a number of common options that are as follows:
#
@@ -1,6 +1,8 @@
module ActionView
+ # = Action View Debug Helper
+ #
+ # Provides a set of methods for making it easier to debug Rails objects.
module Helpers
- # Provides a set of methods for making it easier to debug Rails objects.
module DebugHelper
# Returns a YAML representation of +object+ wrapped with <pre> and </pre>.
# If the object cannot be converted to YAML using +to_yaml+, +inspect+ will be called instead.
@@ -7,6 +7,7 @@
require 'active_support/core_ext/object/blank'
module ActionView
+ # = Action View Form Helpers
module Helpers
# Form helpers are designed to make working with resources much easier
# compared to using vanilla HTML.
@@ -4,6 +4,7 @@
require 'active_support/core_ext/object/blank'
module ActionView
+ # = Action View Form Option Helpers
module Helpers
# Provides a number of methods for turning different kinds of containers into a set of option tags.
# == Options
@@ -4,6 +4,7 @@
require 'active_support/core_ext/object/blank'
module ActionView
+ # = Action View Form Tag Helpers
module Helpers
# Provides a number of methods for creating form tags that doesn't rely on an Active Record object assigned to the template like
# FormHelper does. Instead, you provide the names and values manually.
@@ -1,6 +1,7 @@
require 'action_view/helpers/tag_helper'
module ActionView
+ # = Action View JavaScript Helpers
module Helpers
# Provides functionality for working with JavaScript in your views.
#
@@ -4,6 +4,7 @@
require 'active_support/core_ext/object/blank'
module ActionView
+ # = Action View Prototype Helpers
module Helpers
# Prototype[http://www.prototypejs.org/] is a JavaScript library that provides
# DOM[http://en.wikipedia.org/wiki/Document_Object_Model] manipulation,
@@ -1,6 +1,15 @@
module ActionView #:nodoc:
+ # = Action View Raw Output Helper
module Helpers #:nodoc:
module RawOutputHelper
+ # This method outputs without escaping a string. Since escaping tags is
+ # now default, this can be used when you don't want Rails to automatically
+ # escape tags. This is not recommended if the data is coming from the user's
+ # input.
+ #
+ # For example:
+ #
+ # <%=raw @user.name %>
def raw(stringish)
stringish.to_s.html_safe
end
@@ -1,4 +1,5 @@
module ActionView
+ # = Action View Record Tag Helpers
module Helpers
module RecordTagHelper
# Produces a wrapper DIV element with id and class parameters that
@@ -2,19 +2,25 @@
require 'action_view/helpers/tag_helper'
module ActionView
+ # = Action View Sanitize Helpers
module Helpers #:nodoc:
# The SanitizeHelper module provides a set of methods for scrubbing text of undesired HTML elements.
# These helper methods extend Action View making them callable within your template files.
module SanitizeHelper
- # This +sanitize+ helper will html encode all tags and strip all attributes that aren't specifically allowed.
- # It also strips href/src tags with invalid protocols, like javascript: especially. It does its best to counter any
- # tricks that hackers may use, like throwing in unicode/ascii/hex values to get past the javascript: filters. Check out
+ # This +sanitize+ helper will html encode all tags and strip all attributes that
+ # aren't specifically allowed.
+ #
+ # It also strips href/src tags with invalid protocols, like javascript: especially.
+ # It does its best to counter any tricks that hackers may use, like throwing in
+ # unicode/ascii/hex values to get past the javascript: filters. Check out
# the extensive test suite.
#
# <%= sanitize @article.body %>
#
- # You can add or remove tags/attributes if you want to customize it a bit. See ActionView::Base for full docs on the
- # available options. You can add tags/attributes for single uses of +sanitize+ by passing either the <tt>:attributes</tt> or <tt>:tags</tt> options:
+ # You can add or remove tags/attributes if you want to customize it a bit.
+ # See ActionView::Base for full docs on the available options. You can add
+ # tags/attributes for single uses of +sanitize+ by passing either the
+ # <tt>:attributes</tt> or <tt>:tags</tt> options:
#
# Normal Use
#
@@ -2,16 +2,19 @@
require 'active_support/json'
module ActionView
+ # = Action View Scriptaculous Helpers
module Helpers
- # Provides a set of helpers for calling Scriptaculous JavaScript
- # functions, including those which create Ajax controls and visual effects.
+ # Provides a set of helpers for calling Scriptaculous[http://script.aculo.us/]
+ # JavaScript functions, including those which create Ajax controls and visual
+ # effects.
#
# To be able to use these helpers, you must include the Prototype
# JavaScript framework and the Scriptaculous JavaScript library in your
# pages. See the documentation for ActionView::Helpers::JavaScriptHelper
# for more information on including the necessary JavaScript.
#
# The Scriptaculous helpers' behavior can be tweaked with various options.
+ #
# See the documentation at http://script.aculo.us for more information on
# using these helpers in your application.
module ScriptaculousHelper
@@ -2,6 +2,7 @@
require 'set'
module ActionView
+ # = Action View Tag Helpers
module Helpers #:nodoc:
# Provides methods to generate HTML tags programmatically when you can't use
# a Builder. By default, they output XHTML compliant tags.
@@ -3,6 +3,7 @@
require 'action_view/helpers/tag_helper'
module ActionView
+ # = Action View Text Helpers
module Helpers #:nodoc:
# The TextHelper module provides a set of methods for filtering, formatting
# and transforming strings, which can reduce the amount of inline Ruby code in
@@ -1,21 +1,28 @@
require 'action_view/helpers/tag_helper'
module ActionView
+ # = Action View Translation Helpers
module Helpers
module TranslationHelper
- # Delegates to I18n#translate but also performs three additional functions. First, it'll catch MissingTranslationData exceptions
- # and turn them into inline spans that contains the missing key, such that you can see in a view what is missing where.
+ # Delegates to I18n#translate but also performs three additional functions.
+ # First, it'll catch MissingTranslationData exceptions and turn them into
+ # inline spans that contains the missing key, such that you can see in a
+ # view what is missing where.
#
- # Second, it'll scope the key by the current partial if the key starts with a period. So if you call translate(".foo") from the
- # people/index.html.erb template, you'll actually be calling I18n.translate("people.index.foo"). This makes it less repetitive
- # to translate many keys within the same partials and gives you a simple framework for scoping them consistently. If you don't
- # prepend the key with a period, nothing is converted.
+ # Second, it'll scope the key by the current partial if the key starts
+ # with a period. So if you call <tt>translate(".foo")</tt> from the
+ # <tt>people/index.html.erb</tt> template, you'll actually be calling
+ # <tt>I18n.translate("people.index.foo")</tt>. This makes it less repetitive
+ # to translate many keys within the same partials and gives you a simple framework
+ # for scoping them consistently. If you don't prepend the key with a period,
+ # nothing is converted.
#
- # Third, it'll mark the translation as safe HTML if the key has the suffix "_html" or the last element of the key is the word
- # "html". For example, calling translate("footer_html") or translate("footer.html") will return a safe HTML string that won't
- # be escaped by other HTML helper methods. This naming convention helps to identify translations that include HTML tags so that
+ # Third, it'll mark the translation as safe HTML if the key has the suffix
+ # "_html" or the last element of the key is the word "html". For example,
+ # calling translate("footer_html") or translate("footer.html") will return
+ # a safe HTML string that won't be escaped by other HTML helper methods. This
+ # naming convention helps to identify translations that include HTML tags so that
# you know what kind of output to expect when you call translate in a template.
-
def translate(key, options = {})
translation = I18n.translate(scope_key_by_partial(key), options.merge!(:raise => true))
if html_safe_translation_key?(key) && translation.respond_to?(:html_safe)
@@ -4,6 +4,7 @@
require 'action_dispatch'
module ActionView
+ # = Action View URL Helpers
module Helpers #:nodoc:
# Provides a set of methods for making links and getting URLs that
# depend on the routing subsystem (see ActionDispatch::Routing).
@@ -2,6 +2,8 @@
require 'active_support/core_ext/object/blank'
module ActionView
+ # = Action View Lookup Context
+ #
# LookupContext is the object responsible to hold all information required to lookup
# templates, i.e. view paths and details. The LookupContext is also responsible to
# generate a key, given to view paths, used in the resolver cache lookup. Since
@@ -1,4 +1,5 @@
module ActionView #:nodoc:
+ # = Action View PathSet
class PathSet < Array #:nodoc:
%w(initialize << concat insert push unshift).each do |method|
class_eval <<-METHOD, __FILE__, __LINE__ + 1
@@ -2,6 +2,7 @@
require "rails"
module ActionView
+ # = Action View Railtie
class Railtie < Rails::Railtie
config.action_view = ActiveSupport::OrderedOptions.new
@@ -1,4 +1,5 @@
module ActionView
+ # = Action View Layouts
module Layouts
# Returns the contents that are yielded to a layout, given a name or a block.
#
@@ -1,6 +1,8 @@
require 'active_support/core_ext/object/blank'
module ActionView
+ # = Action View Partials
+ #
# There's also a convenience method for rendering sub templates within the current controller that depends on a
# single object (we call this kind of sub templates for partials). It relies on the fact that partials should
# follow the naming convention of being prefixed with an underscore -- as to separate them from regular
@@ -1,6 +1,7 @@
require 'active_support/core_ext/object/try'
module ActionView
+ # Action View Rendering
module Rendering
# Returns the result of a render that's dictated by the options hash. The primary options are:
#
@@ -3,6 +3,7 @@
require 'active_support/core_ext/kernel/singleton_class'
module ActionView
+ # = Action View Template
class Template
extend ActiveSupport::Autoload
Oops, something went wrong.

0 comments on commit 5861fde

Please sign in to comment.