Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:lifo/docrails

  • Loading branch information...
commit 5e60e6571384a809598f3118fdc02dac1fd9d7b8 2 parents 51a9703 + 1a50cc3
@neerajdotname neerajdotname authored
Showing with 130 additions and 119 deletions.
  1. +2 −2 actionmailer/lib/action_mailer/base.rb
  2. +1 −1  actionpack/lib/action_controller.rb
  3. +1 −1  actionpack/lib/action_controller/metal/instrumentation.rb
  4. +3 −3 actionpack/lib/action_view/context.rb
  5. +1 −1  actionpack/lib/action_view/helpers/sanitize_helper.rb
  6. +1 −1  actionpack/lib/action_view/helpers/text_helper.rb
  7. +1 −1  actionpack/test/controller/helper_test.rb
  8. +1 −1  actionpack/test/controller/render_test.rb
  9. +1 −1  activemodel/lib/active_model/lint.rb
  10. +1 −1  activemodel/lib/active_model/naming.rb
  11. +1 −1  activemodel/lib/active_model/validator.rb
  12. +6 −6 activerecord/lib/active_record/association_preload.rb
  13. +2 −2 activerecord/lib/active_record/associations.rb
  14. +21 −18 activerecord/lib/active_record/base.rb
  15. +6 −6 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
  16. +1 −1  activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
  17. +2 −2 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
  18. +3 −3 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  19. +1 −1  activerecord/lib/active_record/locale/en.yml
  20. +1 −1  activerecord/test/cases/defaults_test.rb
  21. +1 −1  activeresource/test/cases/base_test.rb
  22. +1 −1  activeresource/test/cases/finder_test.rb
  23. +23 −21 activesupport/lib/active_support/callbacks.rb
  24. +1 −1  activesupport/lib/active_support/xml_mini/rexml.rb
  25. +2 −2 ci/site_config.rb
  26. +25 −19 railties/guides/source/active_record_basics.textile
  27. +6 −6 railties/guides/source/configuring.textile
  28. +8 −8 railties/guides/source/routing.textile
  29. +1 −1  railties/lib/rails.rb
  30. +1 −1  railties/lib/rails/log_subscriber.rb
  31. +1 −1  railties/lib/rails/log_subscriber/test_helper.rb
  32. +1 −1  railties/lib/rails/railtie.rb
  33. +1 −1  railties/lib/rails/test_unit/testing.rake
  34. +1 −1  railties/test/application/initializers/notifications_test.rb
View
4 actionmailer/lib/action_mailer/base.rb
@@ -209,7 +209,7 @@ module ActionMailer #:nodoc:
#
# <%= image_tag attachments['photo.png'].url -%>
#
- # As we are using ActionView's +image_tag+ method, you can pass in any other options you want:
+ # As we are using Action View's +image_tag+ method, you can pass in any other options you want:
#
# <h1>Please Don't Cringe</h1>
#
@@ -739,7 +739,7 @@ def deprecated_url_options
end
# This module will complain if the user tries to set default_url_options
- # directly instead of through the config object. In ActionMailer's Railtie,
+ # directly instead of through the config object. In Action Mailer's Railtie,
# we include the url_helpers of the router, which will override this module
extend DeprecatedUrlOptions
View
2  actionpack/lib/action_controller.rb
@@ -67,7 +67,7 @@ module ActionController
require 'action_view'
require 'action_controller/vendor/html-scanner'
-# Common ActiveSupport usage in ActionController
+# Common Active Support usage in Action Controller
require 'active_support/concern'
require 'active_support/core_ext/class/attribute_accessors'
require 'active_support/core_ext/load_error'
View
2  actionpack/lib/action_controller/metal/instrumentation.rb
@@ -2,7 +2,7 @@
module ActionController
# Adds instrumentation to several ends in ActionController::Base. It also provides
- # some hooks related with process_action, this allows an ORM like ActiveRecord
+ # some hooks related with process_action, this allows an ORM like Active Record
# and/or DataMapper to plug in ActionController and show related information.
#
# Check ActiveRecord::Railties::ControllerRuntime for an example.
View
6 actionpack/lib/action_view/context.rb
@@ -3,8 +3,8 @@ module CompiledTemplates #:nodoc:
# holds compiled template code
end
- # ActionView contexts are supplied to ActionController
- # to render template. The default ActionView 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
@@ -21,7 +21,7 @@ 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 ActionView context can also mix in ActionView's
+ # An Action View context can also mix in Action View's
# helpers. In order to mix in helpers, a context must
# implement:
#
View
2  actionpack/lib/action_view/helpers/sanitize_helper.rb
@@ -4,7 +4,7 @@
module ActionView
module Helpers #:nodoc:
# The SanitizeHelper module provides a set of methods for scrubbing text of undesired HTML elements.
- # These helper methods extend ActionView making them callable within your template files.
+ # 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
View
2  actionpack/lib/action_view/helpers/text_helper.rb
@@ -6,7 +6,7 @@ module ActionView
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
- # your views. These helper methods extend ActionView making them callable
+ # your views. These helper methods extend Action View making them callable
# within your template files.
module TextHelper
# The preferred method of outputting text in your views is to use the
View
2  actionpack/test/controller/helper_test.rb
@@ -122,7 +122,7 @@ def test_all_helpers_with_alternate_helper_dir
def test_helper_proxy
methods = AllHelpersController.helpers.methods.map(&:to_s)
- # ActionView
+ # Action View
assert methods.include?('pluralize')
# abc_helper.rb
View
2  actionpack/test/controller/render_test.rb
@@ -275,7 +275,7 @@ def builder_layout_test
render :action => "hello", :layout => "layouts/builder"
end
- # :move: test this in ActionView
+ # :move: test this in Action View
def builder_partial_test
render :action => "hello_world_container"
end
View
2  activemodel/lib/active_model/lint.rb
@@ -1,6 +1,6 @@
# == Active Model Lint Tests
#
-# You can test whether an object is compliant with the ActiveModel API by
+# You can test whether an object is compliant with the Active Model API by
# including <tt>ActiveModel::Lint::Tests</tt> in your TestCase. It will include
# tests that tell you whether your object is fully compliant, or if not,
# which aspects of the API are not implemented.
View
2  activemodel/lib/active_model/naming.rb
@@ -49,7 +49,7 @@ def human(options={})
# BookCover.model_name.human #=> "Book cover"
#
# Providing the functionality that ActiveModel::Naming provides in your object
- # is required to pass the ActiveModel Lint test. So either extending the provided
+ # is required to pass the Active Model Lint test. So either extending the provided
# method below, or rolling your own is required..
module Naming
# Returns an ActiveModel::Name object for module. It can be
View
2  activemodel/lib/active_model/validator.rb
@@ -130,7 +130,7 @@ def validate(record)
# in the options hash invoking the validate_each method passing in the
# record, attribute and value.
#
- # All ActiveModel validations are built on top of this Validator.
+ # All Active Model validations are built on top of this Validator.
class EachValidator < Validator
attr_reader :attributes
View
12 activerecord/lib/active_record/association_preload.rb
@@ -6,7 +6,7 @@ module ActiveRecord
module AssociationPreload #:nodoc:
extend ActiveSupport::Concern
- # Implements the details of eager loading of ActiveRecord associations.
+ # Implements the details of eager loading of Active Record associations.
# Application developers should not use this module directly.
#
# ActiveRecord::Base is extended with this module. The source code in
@@ -18,7 +18,7 @@ module AssociationPreload #:nodoc:
# The first one is by using table joins. This was only strategy available
# prior to Rails 2.1. Suppose that you have an Author model with columns
# 'name' and 'age', and a Book model with columns 'name' and 'sales'. Using
- # this strategy, ActiveRecord would try to retrieve all data for an author
+ # this strategy, Active Record would try to retrieve all data for an author
# and all of its books via a single query:
#
# SELECT * FROM authors
@@ -31,7 +31,7 @@ module AssociationPreload #:nodoc:
# 'books' table is useful; the joined 'authors' data is just redundant, and
# processing this redundant data takes memory and CPU time. The problem
# quickly becomes worse and worse as the level of eager loading increases
- # (i.e. if ActiveRecord is to eager load the associations' associations as
+ # (i.e. if Active Record is to eager load the associations' associations as
# well).
#
# The second strategy is to use multiple database queries, one for each
@@ -45,7 +45,7 @@ module AssociationPreload #:nodoc:
module ClassMethods
protected
- # Eager loads the named associations for the given ActiveRecord record(s).
+ # Eager loads the named associations for the given Active Record record(s).
#
# In this description, 'association name' shall refer to the name passed
# to an association creation method. For example, a model that specifies
@@ -80,7 +80,7 @@ module ClassMethods
# { :author => :avatar }
# [ :books, { :author => :avatar } ]
#
- # +preload_options+ contains options that will be passed to ActiveRecord#find
+ # +preload_options+ contains options that will be passed to ActiveRecord::Base#find
# (which is called under the hood for preloading records). But it is passed
# only one level deep in the +associations+ argument, i.e. it's not passed
# to the child associations when +associations+ is a Hash.
@@ -166,7 +166,7 @@ def set_association_single_records(id_to_record_map, reflection_name, associated
end
end
- # Given a collection of ActiveRecord objects, constructs a Hash which maps
+ # Given a collection of Active Record objects, constructs a Hash which maps
# the objects' IDs to the relevant objects. Returns a 2-tuple
# <tt>(id_to_record_map, ids)</tt> where +id_to_record_map+ is the Hash,
# and +ids+ is an Array of record IDs.
View
4 activerecord/lib/active_record/associations.rb
@@ -711,7 +711,7 @@ def association_instance_set(name, association)
#
# The +traps+ association on +Dungeon+ and the the +dungeon+ association on +Trap+ are the inverse of each other and the
# inverse of the +dungeon+ association on +EvilWizard+ is the +evil_wizard+ association on +Dungeon+ (and vice-versa). By default,
- # +ActiveRecord+ doesn't do know anything about these inverse relationships and so no object loading optimisation is possible. For example:
+ # Active Record doesn't know anything about these inverse relationships and so no object loading optimisation is possible. For example:
#
# d = Dungeon.first
# t = d.traps.first
@@ -721,7 +721,7 @@ def association_instance_set(name, association)
#
# The +Dungeon+ instances +d+ and <tt>t.dungeon</tt> in the above example refer to the same object data from the database, but are
# actually different in-memory copies of that data. Specifying the <tt>:inverse_of</tt> option on associations lets you tell
- # +ActiveRecord+ about inverse relationships and it will optimise object loading. For example, if we changed our model definitions to:
+ # Active Record about inverse relationships and it will optimise object loading. For example, if we changed our model definitions to:
#
# class Dungeon < ActiveRecord::Base
# has_many :traps, :inverse_of => :dungeon
View
39 activerecord/lib/active_record/base.rb
@@ -14,6 +14,7 @@
require 'active_support/core_ext/string/behavior'
require 'active_support/core_ext/kernel/singleton_class'
require 'active_support/core_ext/module/delegation'
+require 'active_support/core_ext/module/introspection'
require 'active_support/core_ext/object/duplicable'
require 'active_support/core_ext/object/blank'
require 'arel'
@@ -647,29 +648,14 @@ def table_name
reset_table_name
end
+ # Returns a quoted version of the table name, used to construct SQL statements.
def quoted_table_name
@quoted_table_name ||= connection.quote_table_name(table_name)
end
+ # Computes the table name, (re)sets it internally, and returns it.
def reset_table_name #:nodoc:
- base = base_class
-
- name =
- # STI subclasses always use their superclass' table.
- unless self == base
- base.table_name
- else
- # Nested classes are prefixed with singular parent table name.
- if parent < ActiveRecord::Base && !parent.abstract_class?
- contained = parent.table_name
- contained = contained.singularize if parent.pluralize_table_names
- contained << '_'
- end
- name = "#{full_table_name_prefix}#{contained}#{undecorated_table_name(base.name)}#{table_name_suffix}"
- end
-
- set_table_name(name)
- name
+ self.table_name = compute_table_name
end
def full_table_name_prefix #:nodoc:
@@ -1001,6 +987,23 @@ def undecorated_table_name(class_name = base_class.name)
table_name
end
+ # Computes and returns a table name according to default conventions.
+ def compute_table_name
+ base = base_class
+ if self == base
+ # Nested classes are prefixed with singular parent table name.
+ if parent < ActiveRecord::Base && !parent.abstract_class?
+ contained = parent.table_name
+ contained = contained.singularize if parent.pluralize_table_names
+ contained << '_'
+ end
+ "#{full_table_name_prefix}#{contained}#{undecorated_table_name(name)}#{table_name_suffix}"
+ else
+ # STI subclasses always use their superclass' table.
+ base.table_name
+ end
+ end
+
# Enables dynamic finders like <tt>find_by_user_name(user_name)</tt> and <tt>find_by_user_name_and_password(user_name, password)</tt>
# that are turned into <tt>where(:user_name => user_name).first</tt> and <tt>where(:user_name => user_name, :password => :password).first</tt>
# respectively. Also works for <tt>all</tt> by using <tt>find_all_by_amount(50)</tt> that is turned into <tt>where(:amount => 50).all</tt>.
View
12 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -9,7 +9,7 @@ class ConnectionTimeoutError < ConnectionNotEstablished
end
module ConnectionAdapters
- # Connection pool base class for managing ActiveRecord database
+ # Connection pool base class for managing Active Record database
# connections.
#
# == Introduction
@@ -30,12 +30,12 @@ module ConnectionAdapters
# Connections can be obtained and used from a connection pool in several
# ways:
#
- # 1. Simply use ActiveRecord::Base.connection as with ActiveRecord 2.1 and
+ # 1. Simply use ActiveRecord::Base.connection as with Active Record 2.1 and
# earlier (pre-connection-pooling). Eventually, when you're done with
# the connection(s) and wish it to be returned to the pool, you call
# ActiveRecord::Base.clear_active_connections!. This will be the
- # default behavior for ActiveRecord when used in conjunction with
- # ActionPack's request handling cycle.
+ # default behavior for Active Record when used in conjunction with
+ # Action Pack's request handling cycle.
# 2. Manually check out a connection from the pool with
# ActiveRecord::Base.connection_pool.checkout. You are responsible for
# returning this connection to the pool when finished by calling
@@ -265,7 +265,7 @@ def checkout_and_verify(c)
end
# ConnectionHandler is a collection of ConnectionPool objects. It is used
- # for keeping separate connection pools for ActiveRecord models that connect
+ # for keeping separate connection pools for Active Record models that connect
# to different databases.
#
# For example, suppose that you have 5 models, with the following hierarchy:
@@ -285,7 +285,7 @@ def checkout_and_verify(c)
# is not the same as the one used by Book/ScaryBook/GoodBook.
#
# Normally there is only a single ConnectionHandler instance, accessible via
- # ActiveRecord::Base.connection_handler. ActiveRecord models use this to
+ # ActiveRecord::Base.connection_handler. Active Record models use this to
# determine that connection pool that they should use.
class ConnectionHandler
def initialize(pools = {})
View
2  activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
@@ -103,7 +103,7 @@ def retrieve_connection
connection_handler.retrieve_connection(self)
end
- # Returns true if +ActiveRecord+ is connected.
+ # Returns true if Active Record is connected.
def connected?
connection_handler.connected?(self)
end
View
4 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -15,7 +15,7 @@
module ActiveRecord
module ConnectionAdapters # :nodoc:
- # ActiveRecord supports multiple database systems. AbstractAdapter and
+ # Active Record supports multiple database systems. AbstractAdapter and
# related classes form the abstraction layer which makes this possible.
# An AbstractAdapter represents a connection to a database, and provides an
# abstract interface for database-specific functionality such as establishing
@@ -59,7 +59,7 @@ def supports_migrations?
end
# Can this adapter determine the primary key for tables not attached
- # to an ActiveRecord class, such as join tables? Backend specific, as
+ # to an Active Record class, such as join tables? Backend specific, as
# the abstract adapter always returns +false+.
def supports_primary_key?
false
View
6 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -224,7 +224,7 @@ def active?
if @connection.respond_to?(:status)
@connection.status == PGconn::CONNECTION_OK
else
- # We're asking the driver, not ActiveRecord, so use @connection.query instead of #query
+ # We're asking the driver, not Active Record, so use @connection.query instead of #query
@connection.query 'SELECT 1'
true
end
@@ -258,7 +258,7 @@ def supports_migrations?
true
end
- # Does PostgreSQL support finding primary key on non-ActiveRecord tables?
+ # Does PostgreSQL support finding primary key on non-Active Record tables?
def supports_primary_key? #:nodoc:
true
end
@@ -925,7 +925,7 @@ def configure_connection
# Use standard-conforming strings if available so we don't have to do the E'...' dance.
set_standard_conforming_strings
- # If using ActiveRecord's time zone support configure the connection to return
+ # If using Active Record's time zone support configure the connection to return
# TIMESTAMP WITH ZONE types in UTC.
execute("SET time zone 'UTC'") if ActiveRecord::Base.default_timezone == :utc
end
View
2  activerecord/lib/active_record/locale/en.yml
@@ -4,7 +4,7 @@ en:
#created_at: "Created at"
#updated_at: "Updated at"
- # ActiveRecord models configuration
+ # Active Record models configuration
activerecord:
errors:
messages:
View
2  activerecord/test/cases/defaults_test.rb
@@ -43,7 +43,7 @@ def test_multiline_default_text
class DefaultsTestWithoutTransactionalFixtures < ActiveRecord::TestCase
# ActiveRecord::Base#create! (and #save and other related methods) will
# open a new transaction. When in transactional fixtures mode, this will
- # cause ActiveRecord to create a new savepoint. However, since MySQL doesn't
+ # cause Active Record to create a new savepoint. However, since MySQL doesn't
# support DDL transactions, creating a table will result in any created
# savepoints to be automatically released. This in turn causes the savepoint
# release code in AbstractAdapter#transaction to fail.
View
2  activeresource/test/cases/base_test.rb
@@ -52,7 +52,7 @@ def setup
:children => [{:name => 'Natacha'}]},
{:name => 'Milena',
:children => []}]}]}.to_xml(:root => 'customer')
- # - resource with yaml array of strings; for ActiveRecords using serialize :bar, Array
+ # - resource with yaml array of strings; for ARs using serialize :bar, Array
@marty = <<-eof.strip
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<person>
View
2  activeresource/test/cases/finder_test.rb
@@ -50,7 +50,7 @@ def setup
:children => [{:name => 'Natacha'}]},
{:name => 'Milena',
:children => []}]}]}.to_xml(:root => 'customer')
- # - resource with yaml array of strings; for ActiveRecords using serialize :bar, Array
+ # - resource with yaml array of strings; for ARs using serialize :bar, Array
@marty = <<-eof.strip
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<person>
View
44 activesupport/lib/active_support/callbacks.rb
@@ -445,11 +445,13 @@ def __update_callbacks(name, filters = [], block = nil) #:nodoc:
# Use skip_callback to skip any defined one.
#
# When creating or skipping callbacks, you can specify conditions that
- # are always the same for a given key. For instance, in ActionPack,
+ # are always the same for a given key. For instance, in Action Pack,
# we convert :only and :except conditions into per-key conditions.
#
# before_filter :authenticate, :except => "index"
+ #
# becomes
+ #
# dispatch_callback :before, :authenticate, :per_key => {:unless => proc {|c| c.action_name == "index"}}
#
# Per-Key conditions are evaluated only once per use of a given key.
@@ -510,33 +512,33 @@ def reset_callbacks(symbol)
__define_runner(symbol)
end
- # Define callbacks types.
- #
- # ==== Example
+ # Defines callbacks types:
#
# define_callbacks :validate
#
- # ==== Options
+ # This macro accepts the following options:
#
# * <tt>:terminator</tt> - Indicates when a before filter is considered
# to be halted.
#
# define_callbacks :validate, :terminator => "result == false"
#
- # In the example above, if any before validate callbacks returns false,
- # other callbacks are not executed. Defaults to "false".
+ # In the example above, if any before validate callbacks returns +false+,
+ # other callbacks are not executed. Defaults to "false", meaning no value
+ # halts the chain.
#
# * <tt>:rescuable</tt> - By default, after filters are not executed if
- # the given block or an before_filter raises an error. Supply :rescuable => true
- # to change this behavior.
+ # the given block or a before filter raises an error. Set this option to
+ # true to change this behavior.
#
# * <tt>:scope</tt> - Indicates which methods should be executed when a class
- # is given as callback:
+ # is given as callback. Defaults to <tt>[:kind]</tt>.
#
# class Audit
# def before(caller)
# puts 'Audit: before is called'
# end
+ #
# def before_save(caller)
# puts 'Audit: before_save is called'
# end
@@ -544,8 +546,10 @@ def reset_callbacks(symbol)
#
# class Account
# include ActiveSupport::Callbacks
+ #
# define_callbacks :save
# set_callback :save, :before, Audit.new
+ #
# def save
# run_callbacks :save do
# puts 'save in main'
@@ -553,22 +557,20 @@ def reset_callbacks(symbol)
# end
# end
#
- # In the above case if you execute Account.new.save then method "before" of Audit class
- # will be called. Now change the class "Account" and pass "scope" to method "define_callbacks".
+ # In the above case whenever you save an account the method <tt>Audit#before</tt> will
+ # be called. On the other hand
#
- # define_callbacks :save, :scope => [:kind, :name]
+ # define_callbacks :save, :scope => [:kind, :name]
#
- # Now if you invoke Account.new.save then method "before_save" of Audit will be called
- # instead of method "before".
+ # would trigger <tt>Audit#before_save</tt> instead. That's constructed by calling
+ # <tt>"#{kind}_#{name}"</tt> on the given instance. In this case "kind" is "before" and
+ # "name" is "save".
#
- # When you do not pass any scope then the default value of scope ":kind" is implicitly being
- # passed. In the above case method "before_save" is constructed by calling "#{kind}_#{name}"
- # in the given class. In this case "kind" is "before" and "name" is "save".
+ # A declaration like
#
- # Although ":kind" is the default scope that is passed, it is possible to not to make use of ":kind".
- # define_callbacks :save, :scope => [:name] . A declaration like this would call "save" method of
- # Audit class since ":kind" is skipped.
+ # define_callbacks :save, :scope => [:name]
#
+ # would call <tt>Audit#save</tt>.
#
def define_callbacks(*callbacks)
config = callbacks.last.is_a?(Hash) ? callbacks.pop : {}
View
2  activesupport/lib/active_support/xml_mini/rexml.rb
@@ -11,7 +11,7 @@ module XmlMini_REXML #:nodoc:
# Parse an XML Document string or IO into a simple hash
#
# Same as XmlSimple::xml_in but doesn't shoot itself in the foot,
- # and uses the defaults from ActiveSupport
+ # and uses the defaults from Active Support.
#
# data::
# XML Document string or IO to parse
View
4 ci/site_config.rb
@@ -6,8 +6,8 @@
# EMAIL NOTIFICATION
# ------------------
-# CruiseControl.rb can notify you about build status via email. It uses ActionMailer component of Ruby on Rails
-# framework. Obviously, ActionMailer needs to know how to send out email messages.
+# CruiseControl.rb can notify you about build status via email. It uses the Action Mailer component of Ruby on Rails
+# framework. Obviously, Action Mailer needs to know how to send out email messages.
# If you have an SMTP server on your network, and it needs no authentication, write this in your site_config.rb:
#
ActionMailer::Base.smtp_settings = {
View
44 railties/guides/source/active_record_basics.textile
@@ -32,16 +32,16 @@ Active Record gives us several mechanisms, the most important being the ability
* Validate models before they get persisted to the database
* Perform database operations in an object-oriented fashion.
-h3. Convention over Configuration in ActiveRecord
+h3. Convention over Configuration in Active Record
-When writing applications using other programming languages or frameworks, it may be necessary to write a lot of configuration code. This is particularly true for ORM frameworks in general. However, if you follow the conventions adopted by Rails, you'll need to write very little configuration (in some case no configuration at all) when creating ActiveRecord models. The idea is that if you configure your applications in the very same way most of the times then this should be the default way. In this cases, explicit configuration would be needed only in those cases where you can't follow the conventions for any reason.
+When writing applications using other programming languages or frameworks, it may be necessary to write a lot of configuration code. This is particularly true for ORM frameworks in general. However, if you follow the conventions adopted by Rails, you'll need to write very little configuration (in some case no configuration at all) when creating Active Record models. The idea is that if you configure your applications in the very same way most of the times then this should be the default way. In this cases, explicit configuration would be needed only in those cases where you can't follow the conventions for any reason.
h4. Naming Conventions
-By default, ActiveRecord uses some naming conventions to find out how the mapping between models and database tables should be created. Rails will pluralize your class names to find the respective database table. So, for a class +Book+, you should have a database table called *books*. The Rails pluralization mechanisms are very powerful, being capable to pluralize (and singularize) both regular and irregular words. When using class names composed of two or more words, the model class name should follow the Ruby conventions, using the camelCase form, while the table name must contain the words separated by underscores. Examples:
+By default, Active Record uses some naming conventions to find out how the mapping between models and database tables should be created. Rails will pluralize your class names to find the respective database table. So, for a class +Book+, you should have a database table called *books*. The Rails pluralization mechanisms are very powerful, being capable to pluralize (and singularize) both regular and irregular words. When using class names composed of two or more words, the model class name should follow the Ruby conventions, using the camelCase form, while the table name must contain the words separated by underscores. Examples:
-* Database Table - Plural with underscores separating words i.e. (book_clubs)
-* Model Class - Singular with the first letter of each word capitalized i.e. (BookClub)
+* Database Table - Plural with underscores separating words (e.g., book_clubs)
+* Model Class - Singular with the first letter of each word capitalized (e.g., BookClub)
|_.Model / Class |_.Table / Schema |
|Post |posts|
@@ -53,30 +53,32 @@ By default, ActiveRecord uses some naming conventions to find out how the mappin
h4. Schema Conventions
-ActiveRecord uses naming conventions for the columns in database tables, depending on the purpose of these columns.
+Active Record uses naming conventions for the columns in database tables, depending on the purpose of these columns.
-* *Foreign keys* - These fields should be named following the pattern table_id i.e. (item_id, order_id). These are the fields that ActiveRecord will look for when you create associations between your models.
-* *Primary keys* - By default, ActiveRecord will use an integer column named "id" as the table's primary key. When using "Rails Migrations":migrations.html to create your tables, this column will be automatically created.
+* *Foreign keys* - These fields should be named following the pattern table_id (e.g., item_id, order_id). These are the fields that Active Record will look for when you create associations between your models.
+* *Primary keys* - By default, Active Record will use an integer column named "id" as the table's primary key. When using "Rails Migrations":migrations.html to create your tables, this column will be automatically created.
-There are also some optional column names that will create additional features to ActiveRecord instances:
+There are also some optional column names that will create additional features to Active Record instances:
-* *created_at / created_on* - ActiveRecord will store the current date and time to this field when creating the record.
-* *updated_at / updated_on* - ActiveRecord will store the current date and times to this field when updating the record.
+* *created_at* - Automatically gets set to the current date and time when the record is first created.
+* *created_on* - Automatically gets set to the current date when the record is first created.
+* *updated_at* - Automatically gets set to the current date and time whenever the record is updated.
+* *updated_on* - Automatically gets set to the current date whenever the record is updated.
* *lock_version* - Adds "optimistic locking":http://api.rubyonrails.com/classes/ActiveRecord/Locking.html to a model.
* *type* - Specifies that the model uses "Single Table Inheritance":http://api.rubyonrails.com/classes/ActiveRecord/Base.html
* *(table_name)_count* - Used to cache the number of belonging objects on associations. For example, a +comments_count+ column in a +Post+ class that has many instances of +Comment+ will cache the number of existent comments for each post.
-NOTE: While these column names are optional they are in fact reserved by ActiveRecord. Steer clear of reserved keywords unless you want the extra functionality. For example, "type" is a reserved keyword used to designate a table using Single Table Inheritance. If you are not using STI, try an analogous keyword like "context", that may still accurately describe the data you are modeling.
+NOTE: While these column names are optional they are in fact reserved by Active Record. Steer clear of reserved keywords unless you want the extra functionality. For example, "type" is a reserved keyword used to designate a table using Single Table Inheritance. If you are not using STI, try an analogous keyword like "context", that may still accurately describe the data you are modeling.
-h3. Creating ActiveRecord Models
+h3. Creating Active Record Models
-It's very easy to create ActiveRecord models. All you have to do is to subclass the ActiveRecord::Base class and you're good to go:
+It's very easy to create Active Record models. All you have to do is to subclass the +ActiveRecord::Base+ class and you're good to go:
<ruby>
class Product < ActiveRecord::Base; end
</ruby>
-This will create a +Product+ model, mapped to a *products* table at the database. By doing this you'll also have the ability to map the columns of each row in that table with the attributes of the instances of your model. So, suppose that the *products* table was created using a SQL sentence like:
+This will create a +Product+ model, mapped to a *products* table at the database. By doing this you'll also have the ability to map the columns of each row in that table with the attributes of the instances of your model. So, suppose that the *products* table was created using an SQL sentence like:
<sql>
CREATE TABLE products (
@@ -99,12 +101,15 @@ h3. Overriding the Naming Conventions
What if you need to follow a different naming convention or need to use your Rails application with a legacy database? No problem, you can easily override the default conventions.
You can use the +ActiveRecord::Base.set_table_name+ method to specify the table name that should be used:
+
<ruby>
class Product < ActiveRecord::Base
set_table_name "PRODUCT"
end
</ruby>
+
If you do so, you will have to define manually the class name that is hosting the fixtures (class_name.yml) using the +set_fixture_class+ method in your test definition:
+
<ruby>
class FunnyJoke < ActiveSupport::TestCase
set_fixture_class :funny_jokes => 'Joke'
@@ -113,7 +118,8 @@ class FunnyJoke < ActiveSupport::TestCase
end
</ruby>
-It's also possible to override the column that should be used as the table's primary key. Use the +ActiveRecord::Base.set_primary_key+ method for that:
+It's also possible to override the column that should be used as the table's primary key using the +ActiveRecord::Base.set_primary_key+ method:
+
<ruby>
class Product < ActiveRecord::Base
set_primary_key "product_id"
@@ -122,7 +128,7 @@ end
h3. Reading and Writing Data
-CRUD is an acronym for the four verbs we use to operate on data: Create, Read, Update, Delete. Active Record automatically creates methods to allow an application to read and manipulate data stored within its tables.
+CRUD is an acronym for the four verbs we use to operate on data: *C*reate, *R*ead, *U*pdate and *D*elete. Active Record automatically creates methods to allow an application to read and manipulate data stored within its tables.
h4. Create
@@ -155,7 +161,7 @@ Finally, passing a block to either create or new will return a new User object:
h4. Read
-ActiveRecord provides a rich API for accessing data within a database. Below are a few examples of different data access methods provided by ActiveRecord.
+Active Record provides a rich API for accessing data within a database. Below are a few examples of different data access methods provided by Active Record.
<ruby>
# return all records
@@ -163,7 +169,7 @@ ActiveRecord provides a rich API for accessing data within a database. Below are
</ruby>
<ruby>
- # return first record
+ # return the first record
user = User.first
</ruby>
View
12 railties/guides/source/configuring.textile
@@ -135,7 +135,7 @@ h4. Configuring Action Controller
* +config.action_controller.allow_concurrency+ should be set to +true+ to allow concurrent (threadsafe) action processing. Set to +false+ by default. You probably don't want to call this one directly, though, because a series of other adjustments need to be made for threadsafe mode to work properly. Instead, you should simply call +config.threadsafe!+ inside your +production.rb+ file, which makes all the necessary adjustments.
-WARNING: Threadsafe operation in incompatible with the normal workings of development mode Rails. In particular, automatic dependency loading and class reloading are automatically disabled when you call +config.threadsafe!+.
+WARNING: Threadsafe operation is incompatible with the normal workings of development mode Rails. In particular, automatic dependency loading and class reloading are automatically disabled when you call +config.threadsafe!+.
* +config.action_controller.param_parsers+ provides an array of handlers that can extract information from incoming HTTP requests and add it to the +params+ hash. By default, parsers for multipart forms, URL-encoded forms, XML, and JSON are active.
@@ -167,9 +167,9 @@ The caching code adds two additional settings:
The Active Record session store can also be configured:
-* +ActiveRecord::SessionStore::Session.table_name+ sets the name of the table uses to store sessions. Defaults to +sessions+.
+* +ActiveRecord::SessionStore::Session.table_name+ sets the name of the table used to store sessions. Defaults to +sessions+.
-* +ActiveRecord::SessionStore::Session.primary_key+ sets the name of the ID column uses in the sessions table. Defaults to +session_id+.
+* +ActiveRecord::SessionStore::Session.primary_key+ sets the name of the ID column used in the sessions table. Defaults to +session_id+.
* +ActiveRecord::SessionStore::Session.data_column_name+ sets the name of the column which stores marshaled session data. Defaults to +data+.
@@ -235,9 +235,9 @@ h4. Configuring Active Support
There are a few configuration options available in Active Support:
-* +config.active_support.escape_html_entities_in_json+ enables or disables the escaping of HTML entities in JSON serialization. Defaults to _true_.
+* +config.active_support.escape_html_entities_in_json+ enables or disables the escaping of HTML entities in JSON serialization. Defaults to +true+.
-* +config.active_support.use_standard_json_time_format+ enables or disables serializing dates to ISO 8601 format. Defaults to _false_.
+* +config.active_support.use_standard_json_time_format+ enables or disables serializing dates to ISO 8601 format. Defaults to +false+.
* +ActiveSupport::BufferedLogger.silencer+ is set to +false+ to disable the ability to silence logging in a block. The default is +true+.
@@ -247,7 +247,7 @@ There are a few configuration options available in Active Support:
h3. Using Initializers
-After it loads the framework plus any gems and plugins in your application, Rails turns to loading initializers. An initializer is any file of ruby code stored under +config/initializers+ in your application. You can use initializers to hold configuration settings that should be made after all of the frameworks and plugins are loaded.
+After loading the framework and any gems and plugins in your application, Rails turns to loading initializers. An initializer is any file of Ruby code stored under +config/initializers+ in your application. You can use initializers to hold configuration settings that should be made after all of the frameworks and plugins are loaded.
NOTE: You can use subfolders to organize your initializers if you like, because Rails will look into the whole file hierarchy from the +initializers+ folder on down.
View
16 railties/guides/source/routing.textile
@@ -32,7 +32,7 @@ the request is dispatched to the +patients+ controller's +show+ action with <tt>
h4. Generating URLs from Code
-You can also generate routes. If your application contains this code:
+You can also generate URLs. If your application contains this code:
<ruby>
@patient = Patient.find(17)
@@ -308,7 +308,7 @@ You are not limited to the seven routes that RESTful routing creates by default.
h5. Adding Member Routes
-To add a member route, just add +member+ block into resource block:
+To add a member route, just add a +member+ block into the resource block:
<ruby>
resources :photos do
@@ -318,9 +318,9 @@ resources :photos do
end
</ruby>
-This will recognize +/photos/1/preview+ with GET, and route to the +preview+ action of +PhotosController+. It will also create the +preview_photo_url+ and +preview_photo_path+ helpers.
+This will recognize +/photos/1/preview+ with GET, and route to the +preview+ action of +PhotosController+. It will also create the +preview_photo_url+ and +preview_photo_path+ helpers.
-Within the block of member routes, each route name specifies the HTTP verb that it will recognize. You can use +get+, +put+, +post+, or +delete+ here. If you don't have multiple +member+ routes, you can also passing +:on+ to a route.
+Within the block of member routes, each route name specifies the HTTP verb that it will recognize. You can use +get+, +put+, +post+, or +delete+ here. If you don't have multiple +member+ routes, you can also pass +:on+ to a route, eliminating the block:
<ruby>
resources :photos do
@@ -340,9 +340,9 @@ resources :photos do
end
</ruby>
-This will enable Rails to recognize URLs such as +/photos/search+ with GET, and route to the +search+ action of +PhotosController+. It will also create the +search_photos_url+ and +search_photos_path+ route helpers.
+This will enable Rails to recognize URLs such as +/photos/search+ with GET, and route to the +search+ action of +PhotosController+. It will also create the +search_photos_url+ and +search_photos_path+ route helpers.
-Just as with member routes, you can pass +:on+ to a route.
+Just as with member routes, you can pass +:on+ to a route:
<ruby>
resources :photos do
@@ -384,7 +384,7 @@ An incoming URL of +/photos/show/1/2+ will be dispatched to the +show+ action of
h4. Static Segments
-You can specify static segments when creating a route.
+You can specify static segments when creating a route:
<ruby>
match ':controller/:action/:id/with_user/:user_id'
@@ -575,7 +575,7 @@ resources :photos, :constraints => {:id => /[A-Z][A-Z][0-9]+/}
This declaration constrains the +:id+ parameter to match the supplied regular expression. So, in this case, the router would no longer match +/photos/1+ to this route. Instead, +/photos/RR27+ would match.
-You can specify a single constraint to a apply to a number of routes by using the block form:
+You can specify a single constraint to apply to a number of routes by using the block form:
<ruby>
constraints(:id => /[A-Z][A-Z][0-9]+/) do
View
2  railties/lib/rails.rb
@@ -67,7 +67,7 @@ def logger=(logger)
def backtrace_cleaner
@@backtrace_cleaner ||= begin
- # Relies on ActiveSupport, so we have to lazy load to postpone definition until AS has been loaded
+ # Relies on Active Support, so we have to lazy load to postpone definition until AS has been loaded
require 'rails/backtrace_cleaner'
Rails::BacktraceCleaner.new
end
View
2  railties/lib/rails/log_subscriber.rb
@@ -6,7 +6,7 @@ module Rails
# on initialization with solely purpose of logging. The log subscriber dispatches
# notifications to a regirested object based on its given namespace.
#
- # An example would be ActiveRecord log subscriber responsible for logging queries:
+ # An example would be Active Record log subscriber responsible for logging queries:
#
# module ActiveRecord
# class Railtie
View
2  railties/lib/rails/log_subscriber/test_helper.rb
@@ -3,7 +3,7 @@
module Rails
class LogSubscriber
# Provides some helpers to deal with testing log subscribers by setting up
- # notifications. Take for instance ActiveRecord subscriber tests:
+ # notifications. Take for instance Active Record subscriber tests:
#
# class SyncLogSubscriberTest < ActiveSupport::TestCase
# include Rails::LogSubscriber::TestHelper
View
2  railties/lib/rails/railtie.rb
@@ -10,7 +10,7 @@ module Rails
# Every major component of Rails (Action Mailer, Action Controller,
# Action View, Active Record and Active Resource) are all Railties, so each of
# them is responsible to set their own initialization. This makes, for example,
- # Rails absent of any ActiveRecord hook, allowing any other ORM framework to hook in.
+ # Rails absent of any Active Record hook, allowing any other ORM framework to hook in.
#
# Developing a Rails extension does _not_ require any implementation of
# Railtie, but if you need to interact with the Rails framework during
View
2  railties/lib/rails/test_unit/testing.rake
@@ -58,7 +58,7 @@ def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago)
end
-# Recreated here from ActiveSupport because :uncommitted needs it before Rails is available
+# Recreated here from Active Support because :uncommitted needs it before Rails is available
module Kernel
def silence_stderr
old_stderr = STDERR.dup
View
2  railties/test/application/initializers/notifications_test.rb
@@ -37,7 +37,7 @@ def wait
ActiveRecord::Base.logger = logger = MockLogger.new
- # Mimic ActiveRecord notifications
+ # Mimic Active Record notifications
instrument "sql.active_record", :name => "SQL", :sql => "SHOW tables"
wait
Please sign in to comment.
Something went wrong with that request. Please try again.