diff --git a/activerecord/lib/active_record/acts/list.rb b/activerecord/lib/active_record/acts/list.rb index 425ac3856d356..551c41fb6a8bb 100644 --- a/activerecord/lib/active_record/acts/list.rb +++ b/activerecord/lib/active_record/acts/list.rb @@ -6,7 +6,7 @@ def self.append_features(base) base.extend(ClassMethods) end - # This act provides the capabilities for sorting and reordering a number of objects in list. + # This act provides the capabilities for sorting and reordering a number of objects in a list. # The class that has this specified needs to have a "position" column defined as an integer on # the mapped database table. # diff --git a/activerecord/lib/active_record/acts/nested_set.rb b/activerecord/lib/active_record/acts/nested_set.rb index cc120cad4b00c..8b02b358a97ae 100644 --- a/activerecord/lib/active_record/acts/nested_set.rb +++ b/activerecord/lib/active_record/acts/nested_set.rb @@ -7,17 +7,17 @@ def self.append_features(base) end # This acts provides Nested Set functionality. Nested Set is similiar to Tree, but with - # the added feature that you can select the children and all of it's descendants with + # the added feature that you can select the children and all of their descendents with # a single query. A good use case for this is a threaded post system, where you want # to display every reply to a comment without multiple selects. # # A google search for "Nested Set" should point you in the direction to explain the - # data base theory. I figured a bunch of this from + # database theory. I figured out a bunch of this from # http://threebit.net/tutorials/nestedset/tutorial1.html # - # Instead of picturing a leaf node structure with child pointing back to their parent, + # Instead of picturing a leaf node structure with children pointing back to their parent, # the best way to imagine how this works is to think of the parent entity surrounding all - # of it's children, and it's parent surrounding it, etc. Assuming that they are lined up + # of its children, and its parent surrounding it, etc. Assuming that they are lined up # horizontally, we store the left and right boundries in the database. # # Imagine: @@ -42,7 +42,7 @@ def self.append_features(base) # | |___________________________| |___________________________| | # |___________________________________________________________________| # - # The numbers represent the left and right boundries. The table them might + # The numbers represent the left and right boundries. The table then might # look like this: # ID | PARENT | LEFT | RIGHT | DATA # 1 | 0 | 1 | 14 | root @@ -63,10 +63,10 @@ def self.append_features(base) # There are instance methods for all of these. # # The structure is good if you need to group things together; the downside is that - # keeping data integrity is a pain, and both adding and removing and entry + # keeping data integrity is a pain, and both adding and removing an entry # require a full table write. # - # This sets up a before_destroy trigger to prune the tree correctly if one of it's + # This sets up a before_destroy trigger to prune the tree correctly if one of its # elements gets deleted. # module ClassMethods @@ -134,10 +134,10 @@ def unknown? end - # Added a child to this object in the tree. If this object hasn't been initialized, + # Adds a child to this object in the tree. If this object hasn't been initialized, # it gets set up as a root node. Otherwise, this method will update all of the - # other elements in the tree and shift them to the right. Keeping everything - # balanaced. + # other elements in the tree and shift them to the right, keeping everything + # balanced. def add_child( child ) self.reload child.reload @@ -179,17 +179,17 @@ def children_count return (self[right_col_name] - self[left_col_name] - 1)/2 end - # Returns a set of itself and all of it's nested children + # Returns a set of itself and all of its nested children def full_set self.class.find(:all, :conditions => "#{scope_condition} AND (#{left_col_name} BETWEEN #{self[left_col_name]} and #{self[right_col_name]})" ) end - # Returns a set of all of it's children and nested children + # Returns a set of all of its children and nested children def all_children self.class.find(:all, :conditions => "#{scope_condition} AND (#{left_col_name} > #{self[left_col_name]}) and (#{right_col_name} < #{self[right_col_name]})" ) end - # Returns a set of only this entries immediate children + # Returns a set of only this entry's immediate children def direct_children self.class.find(:all, :conditions => "#{scope_condition} and #{parent_column} = #{self.id}") end diff --git a/activerecord/lib/active_record/acts/tree.rb b/activerecord/lib/active_record/acts/tree.rb index 9cf5c3f732175..1c7646b74cd29 100644 --- a/activerecord/lib/active_record/acts/tree.rb +++ b/activerecord/lib/active_record/acts/tree.rb @@ -6,8 +6,8 @@ def self.append_features(base) base.extend(ClassMethods) end - # Specify this act if you want to model a tree structure by providing a parent association and an children - # association. This act assumes that requires that you have a foreign key column, which by default is called parent_id. + # Specify this act if you want to model a tree structure by providing a parent association and a children + # association. This act requires that you have a foreign key column, which by default is called parent_id. # # class Category < ActiveRecord::Base # acts_as_tree :order => "name" @@ -30,13 +30,14 @@ def self.append_features(base) # # In addition to the parent and children associations, the following instance methods are added to the class # after specifying the act: - # * siblings: Return all the children of the parent excluding the current node ([ subchild2 ] when called from subchild1) - # * ancestors: Returns all the ancestors of the current node ([child1, root] when called from subchild2) - # * root: Returns the root of the current node (root when called from subchild2) + # * siblings : Returns all the children of the parent, excluding the current node ([ subchild2 ] when called from subchild1) + # * self_and_siblings : Returns all the children of the parent, including the current node ([ subchild1, subchild2 ] when called from subchild1) + # * ancestors : Returns all the ancestors of the current node ([child1, root] when called from subchild2) + # * root : Returns the root of the current node (root when called from subchild2) module ClassMethods # Configuration options are: # - # * foreign_key - specifies the column name to use for track of the tree (default: parent_id) + # * foreign_key - specifies the column name to use for tracking of the tree (default: parent_id) # * order - makes it possible to sort the children according to this SQL snippet. # * counter_cache - keeps a count in a children_count column if set to true (default: false). def acts_as_tree(options = {}) diff --git a/activerecord/lib/active_record/aggregations.rb b/activerecord/lib/active_record/aggregations.rb index 29cf5c39250aa..6824df9b37140 100644 --- a/activerecord/lib/active_record/aggregations.rb +++ b/activerecord/lib/active_record/aggregations.rb @@ -7,8 +7,8 @@ def self.append_features(base) # Active Record implements aggregation through a macro-like class method called +composed_of+ for representing attributes # as value objects. It expresses relationships like "Account [is] composed of Money [among other things]" or "Person [is] - # composed of [an] address". Each call to the macro adds a description on how the value objects are created from the - # attributes of the entity object (when the entity is initialized either as a new object or from finding an existing) + # composed of [an] address". Each call to the macro adds a description of how the value objects are created from the + # attributes of the entity object (when the entity is initialized either as a new object or from finding an existing object) # and how it can be turned back into attributes (when the entity is saved to the database). Example: # # class Customer < ActiveRecord::Base @@ -88,8 +88,8 @@ def self.append_features(base) # == Writing value objects # # Value objects are immutable and interchangeable objects that represent a given value, such as a Money object representing - # $5. Two Money objects both representing $5 should be equal (through methods such == and <=> from Comparable if ranking makes - # sense). This is unlike a entity objects where equality is determined by identity. An entity class such as Customer can + # $5. Two Money objects both representing $5 should be equal (through methods such as == and <=> from Comparable if ranking + # makes sense). This is unlike entity objects where equality is determined by identity. An entity class such as Customer can # easily have two different objects that both have an address on Hyancintvej. Entity identity is determined by object or # relational unique identifiers (such as primary keys). Normal ActiveRecord::Base classes are entity objects. # diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 87080bf0da3c1..dd0b71b65f4ac 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -22,7 +22,7 @@ def clear_association_cache #:nodoc: # Associations are a set of macro-like class methods for tying objects together through foreign keys. They express relationships like # "Project has one Project Manager" or "Project belongs to a Portfolio". Each macro adds a number of methods to the class which are - # specialized according to the collection or association symbol and the options hash. It works much the same was as Ruby's own attr* + # specialized according to the collection or association symbol and the options hash. It works much the same way as Ruby's own attr* # methods. Example: # # class Project < ActiveRecord::Base @@ -80,7 +80,7 @@ def clear_association_cache #:nodoc: # # === One-to-one associations # - # * Assigning an object to a has_one association automatically saves that object, and the object being replaced (if there is one), in + # * Assigning an object to a has_one association automatically saves that object and the object being replaced (if there is one), in # order to update their primary keys - except if the parent object is unsaved (new_record? == true). # * If either of these saves fail (due to one of the objects being invalid) the assignment statement returns false and the assignment # is cancelled. @@ -164,8 +164,8 @@ def clear_association_cache #:nodoc: # # That'll add another join along the lines of: LEFT OUTER JOIN comments ON comments.post_id = posts.id. And we'll be down to 1 query. # But that shouldn't fool you to think that you can pull out huge amounts of data with no performance penalty just because you've reduced - # the number of queries. The database still needs to send all the data to Active Record and it still needs to be processed. So its no - # catch-all for performance problems, but its a great way to cut down on the number of queries in a situation as the one described above. + # the number of queries. The database still needs to send all the data to Active Record and it still needs to be processed. So it's no + # catch-all for performance problems, but it's a great way to cut down on the number of queries in a situation as the one described above. # # Please note that limited eager loading with has_many and has_and_belongs_to_many associations is not compatible with describing conditions # on these eager tables. This will work: @@ -240,10 +240,10 @@ module ClassMethods # * collection.find - finds an associated object according to the same rules as Base.find. # * collection.build(attributes = {}) - returns a new object of the collection type that has been instantiated # with +attributes+ and linked to this object through a foreign key but has not yet been saved. *Note:* This only works if an - # associated object already exists, not if its nil! + # associated object already exists, not if it's nil! # * collection.create(attributes = {}) - returns a new object of the collection type that has been instantiated # with +attributes+ and linked to this object through a foreign key and that has already been saved (if it passed the validation). - # *Note:* This only works if an associated object already exists, not if its nil! + # *Note:* This only works if an associated object already exists, not if it's nil! # # Example: A Firm class declares has_many :clients, which will add: # * Firm#clients (similar to Clients.find :all, :conditions => "firm_id = #{id}") @@ -271,7 +271,7 @@ module ClassMethods # of this class in lower-case and "_id" suffixed. So a +Person+ class that makes a has_many association will use "person_id" # as the default foreign_key. # * :dependent - if set to :destroy (or true) all the associated objects are destroyed - # alongside this object. Also accepts :nullify which will set the associated objects foriegn key + # alongside this object. Also accepts :nullify which will set the associated object's foreign key # field to NULL. # May not be set if :exclusively_dependent is also set. # * :exclusively_dependent - if set to true all the associated object are deleted in one SQL statement without having their @@ -279,7 +279,7 @@ module ClassMethods # clean-up in before_destroy. The upside is that it's much faster, especially if there's a counter_cache involved. # May not be set if :dependent is also set. # * :finder_sql - specify a complete SQL statement to fetch the association. This is a good way to go for complex - # associations that depends on multiple tables. Note: When this option is used, +find_in_collection+ is _not_ added. + # associations that depend on multiple tables. Note: When this option is used, +find_in_collection+ is _not_ added. # * :counter_sql - specify a complete SQL statement to fetch the size of the association. If +:finder_sql+ is # specified but +:counter_sql+, +:counter_sql+ will be generated by replacing SELECT ... FROM with SELECT COUNT(*) FROM. # @@ -369,7 +369,7 @@ def has_many(association_id, options = {}) # sql fragment, such as "rank = 5". # * :order - specify the order from which the associated object will be picked at the top. Specified as # an "ORDER BY" sql fragment, such as "last_name, first_name DESC" - # * :dependent - if set to :destroy (or true) all the associated object is destroyed when this object is. Also + # * :dependent - if set to :destroy (or true) all the associated objects are destroyed when this object is. Also, # association is assigned. # * :foreign_key - specify the foreign key used for the association. By default this is guessed to be the name # of this class in lower-case and "_id" suffixed. So a +Person+ class that makes a has_one association will use "person_id" @@ -558,8 +558,8 @@ def belongs_to(association_id, options = {}) # of this class in lower-case and "_id" suffixed. So a +Person+ class that makes a has_and_belongs_to_many association # will use "person_id" as the default foreign_key. # * :association_foreign_key - specify the association foreign key used for the association. By default this is - # guessed to be the name of the associated class in lower-case and "_id" suffixed. So the associated class is +Project+ - # that makes a has_and_belongs_to_many association will use "project_id" as the default association foreign_key. + # guessed to be the name of the associated class in lower-case and "_id" suffixed. So if the associated class is +Project+, + # the has_and_belongs_to_many association will use "project_id" as the default association foreign_key. # * :conditions - specify the conditions that the associated object must meet in order to be included as a "WHERE" # sql fragment, such as "authorized = 1". # * :order - specify the order in which the associated objects are returned as a "ORDER BY" sql fragment, such as "last_name, first_name DESC" diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb index fb428c3f316a4..aa3aa2d1a5731 100755 --- a/activerecord/lib/active_record/callbacks.rb +++ b/activerecord/lib/active_record/callbacks.rb @@ -86,7 +86,7 @@ module ActiveRecord # # There are four types of callbacks accepted by the callback macros: Method references (symbol), callback objects, # inline methods (using a proc), and inline eval methods (using a string). Method references and callback objects are the - # recommended approaches, inline methods using a proc is some times appropriate (such as for creating mix-ins), and inline + # recommended approaches, inline methods using a proc are sometimes appropriate (such as for creating mix-ins), and inline # eval methods are deprecated. # # The method reference callbacks work by specifying a protected or private method available in the object, like this: @@ -153,7 +153,7 @@ module ActiveRecord # # == The after_find and after_initialize exceptions # - # Because after_find and after_initialize is called for each object instantiated found by a finder, such as Base.find(:all), we've had + # Because after_find and after_initialize are called for each object found and instantiated by a finder, such as Base.find(:all), we've had # to implement a simple performance constraint (50% more speed on a simple test case). Unlike all the other callbacks, after_find and # after_initialize will only be run if an explicit implementation is defined (def after_find). In that case, all of the # callback types will be called. @@ -263,10 +263,10 @@ def create_with_callbacks #:nodoc: result end - # Is called _before_ Base.save on existing objects that has a record. + # Is called _before_ Base.save on existing objects that have a record. def before_update() end - # Is called _after_ Base.save on existing objects that has a record. + # Is called _after_ Base.save on existing objects that have a record. def after_update() end def update_with_callbacks #:nodoc: @@ -291,11 +291,11 @@ def before_validation_on_create() end def after_validation_on_create() end # Is called _before_ Validations.validate (which is part of the Base.save call) on - # existing objects that has a record. + # existing objects that have a record. def before_validation_on_update() end # Is called _after_ Validations.validate (which is part of the Base.save call) on - # existing objects that has a record. + # existing objects that have a record. def after_validation_on_update() end def valid_with_callbacks #:nodoc: diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index a798c6bb028b9..594e320f6b528 100755 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -20,7 +20,7 @@ def values; map { |k, v| v } end # This type of fixture is in YAML format and the preferred default. YAML is a file format which describes data structures # in a non-verbose, humanly-readable format. It ships with Ruby 1.8.1+. # -# Unlike single-file fixtures, YAML fixtures are stored in a single file per model, which is place in the directory appointed +# Unlike single-file fixtures, YAML fixtures are stored in a single file per model, which are placed in the directory appointed # by Test::Unit::TestCase.fixture_path=(path) (this is automatically configured for Rails, so you can just # put your files in /test/fixtures/). The fixture file ends with the .yml file extension (Rails example: # "/test/fixtures/web_sites.yml"). The format of a YAML fixture file looks like this: @@ -56,7 +56,7 @@ def values; map { |k, v| v } end # = CSV fixtures # # Fixtures can also be kept in the Comma Separated Value format. Akin to YAML fixtures, CSV fixtures are stored -# in a single file, but, instead end with the .csv file extension (Rails example: "/test/fixtures/web_sites.csv") +# in a single file, but instead end with the .csv file extension (Rails example: "/test/fixtures/web_sites.csv") # # The format of this type of fixture file is much more compact than the others, but also a little harder to read by us # humans. The first line of the CSV file is a comma-separated list of field names. The rest of the file is then comprised @@ -103,7 +103,7 @@ def values; map { |k, v| v } end # = Using Fixtures # # Since fixtures are a testing construct, we use them in our unit and functional tests. There are two ways to use the -# fixtures, but first lets take a look at a sample unit test found: +# fixtures, but first let's take a look at a sample unit test found: # # require 'web_site' # @@ -139,7 +139,7 @@ def values; map { |k, v| v } end # # As seen above, the data hash created from the YAML fixtures would have @web_sites["rubyonrails"]["url"] return # "http://www.rubyonrails.org" and @web_sites["google"]["name"] would return "Google". The same fixtures, but loaded -# from a CSV fixture file would be accessible via @web_sites["web_site_1"]["name"] == "Ruby on Rails" and have the individual +# from a CSV fixture file, would be accessible via @web_sites["web_site_1"]["name"] == "Ruby on Rails" and have the individual # fixtures available as instance variables @web_site_1 and @web_site_2. # # If you do not wish to use instantiated fixtures (usually for performance reasons) there are two options. diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index fcb5ad82de9e9..9b93366906efe 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -109,7 +109,7 @@ class IrreversibleMigration < ActiveRecordError#:nodoc: # end # end # - # And some times you need to do something in SQL not abstracted directly by migrations: + # And sometimes you need to do something in SQL not abstracted directly by migrations: # # class MakeJoinUnique < ActiveRecord::Migration # def self.up @@ -123,7 +123,7 @@ class IrreversibleMigration < ActiveRecordError#:nodoc: # # == Using the class after changing table # - # Some times you'll want to add a column in a migration and populate it immediately after. In that case, you'll need + # Sometimes you'll want to add a column in a migration and populate it immediately after. In that case, you'll need # to make a call to Base#reset_column_information in order to ensure that the class has the latest column data from # after the new column was added. Example: # diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 9aec0ca34b57a..de5a01c9be9f4 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -34,7 +34,7 @@ def #{association_type}_with_reflection(association_id, options = {}) end # Reflection allows you to interrogate Active Record classes and objects about their associations and aggregations. - # This information can for example be used in a form builder that took an Active Record object and created input + # This information can, for example, be used in a form builder that took an Active Record object and created input # fields for all of the attributes depending on their type and displayed the associations to other objects. # # You can find the interface for the AggregateReflection and AssociationReflection classes in the abstract MacroReflection class. diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index e9a612495cba0..2c5692c036c90 100644 --- a/activerecord/lib/active_record/transactions.rb +++ b/activerecord/lib/active_record/transactions.rb @@ -24,7 +24,7 @@ def self.append_features(base) # Transactions are protective blocks where SQL statements are only permanent if they can all succeed as one atomic action. # The classic example is a transfer between two accounts where you can only have a deposit if the withdrawal succeeded and - # vice versa. Transaction enforce the integrity of the database and guards the data against program errors or database break-downs. + # vice versa. Transactions enforce the integrity of the database and guard the data against program errors or database break-downs. # So basically you should use transaction blocks whenever you have a number of statements that must be executed together or # not at all. Example: # @@ -62,7 +62,7 @@ def self.append_features(base) # # == Object-level transactions # - # You can enable object-level transactions for Active Record objects, though. You do this by naming the each of the Active Records + # You can enable object-level transactions for Active Record objects, though. You do this by naming each of the Active Records # that you want to enable object-level transactions for, like this: # # Account.transaction(david, mary) do diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index c3a67f9d919a1..1292bff432034 100755 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -29,8 +29,8 @@ def initialize(base) # :nodoc: # Adds an error to the base object instead of any particular attribute. This is used - # to report errors that doesn't tie to any specific attribute, but rather to the object - # as a whole. These error messages doesn't get prepended with any field name when iterating + # to report errors that don't tie to any specific attribute, but rather to the object + # as a whole. These error messages don't get prepended with any field name when iterating # with each_full, so they should be complete sentences. def add_to_base(msg) add(:base, msg) @@ -359,7 +359,7 @@ def validates_presence_of(*attr_names) configuration = { :message => ActiveRecord::Errors.default_error_messages[:blank], :on => :save } configuration.update(attr_names.pop) if attr_names.last.is_a?(Hash) - # can't use validates_each here, because it cannot cope with non-existant attributes, + # can't use validates_each here, because it cannot cope with nonexistent attributes, # while errors.add_on_empty can attr_names.each do |attr_name| send(validation_method(configuration[:on])) do |record| @@ -460,7 +460,7 @@ def validates_length_of(*attrs) # validates_uniqueness_of :user_name, :scope => "account_id" # end # - # When the record is created, a check is performed to make sure that no record exist in the database with the given value for the specified + # When the record is created, a check is performed to make sure that no record exists in the database with the given value for the specified # attribute (that maps to a column). When the record is updated, the same check is made but disregarding the record itself. # # Configuration options: @@ -565,7 +565,7 @@ def validates_exclusion_of(*attr_names) end end - # Validates whether the associated object or objects are all themselves valid. Works with any kind of association. + # Validates whether the associated object or objects are all valid themselves. Works with any kind of association. # # class Book < ActiveRecord::Base # has_many :pages