diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index b71200cd2ad79bbdd5814128bb1d6e5b50a68898..3490057298e0d6060f5f3e4fdb9b4871c17a0ca6 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -172,7 +172,7 @@ def association_instance_set(name, association) @association_cache[name] = association end - # Associations are a set of macro-like class methods for tying objects together through + # \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 @@ -365,11 +365,11 @@ def association_instance_set(name, association) # there is some special behavior you should be aware of, mostly involving the saving of # associated objects. # - # You can set the :autosave option on a has_one, belongs_to, + # You can set the :autosave option on a has_one, belongs_to, # has_many, or has_and_belongs_to_many association. Setting it # to +true+ will _always_ save the members, whereas setting it to +false+ will - # _never_ save the members. More details about :autosave option is available at - # autosave_association.rb . + # _never_ save the members. More details about :autosave option is available at + # AutosaveAssociation. # # === One-to-one associations # @@ -402,7 +402,7 @@ def association_instance_set(name, association) # # == Customizing the query # - # Associations are built from Relations, and you can use the Relation syntax + # \Associations are built from Relations, and you can use the Relation syntax # to customize them. For example, to add a condition: # # class Blog < ActiveRecord::Base @@ -588,10 +588,10 @@ def association_instance_set(name, association) # # If you do not set the +:inverse_of+ record, the association will do its # best to match itself up with the correct inverse. Automatic +:inverse_of+ - # detection only works on :has_many, :has_one, and :belongs_to associations. + # detection only works on +has_many+, +has_one+, and +belongs_to+ associations. # # Extra options on the associations, as defined in the - # +AssociationReflection::INVALID_AUTOMATIC_INVERSE_OPTIONS+ constant, will + # AssociationReflection::INVALID_AUTOMATIC_INVERSE_OPTIONS constant, will # also prevent the association's inverse from being found automatically. # # The automatic guessing of the inverse association uses a heuristic based @@ -605,7 +605,7 @@ def association_instance_set(name, association) # belongs_to :tag, automatic_inverse_of: false # end # - # == Nested Associations + # == Nested \Associations # # You can actually specify *any* association with the :through option, including an # association which has a :through option itself. For example: @@ -648,7 +648,7 @@ def association_instance_set(name, association) # add a Commenter in the example above, there would be no way to tell how to set up the # intermediate Post and Comment objects. # - # == Polymorphic Associations + # == Polymorphic \Associations # # Polymorphic associations on models are not restricted on what types of models they # can be associated with. Rather, they specify an interface that a +has_many+ association @@ -810,7 +810,7 @@ def association_instance_set(name, association) # For example if all the addressables are either of class Person or Company then a total # of 3 queries will be executed. The list of addressable types to load is determined on # the back of the addresses loaded. This is not supported if Active Record has to fallback - # to the previous implementation of eager loading and will raise ActiveRecord::EagerLoadPolymorphicError. + # to the previous implementation of eager loading and will raise ActiveRecord::EagerLoadPolymorphicError. # The reason is that the parent model's type is a column value so its corresponding table # name cannot be put in the +FROM+/+JOIN+ clauses of that query. # @@ -1045,7 +1045,7 @@ module ClassMethods # An empty array is returned if none are found. # [collection<<(object, ...)] # Adds one or more objects to the collection by setting their foreign keys to the collection's primary key. - # Note that this operation instantly fires update sql without waiting for the save or update call on the + # Note that this operation instantly fires update SQL without waiting for the save or update call on the # parent object, unless the parent object is a new record. # [collection.delete(object, ...)] # Removes one or more objects from the collection by setting their foreign keys to +NULL+. @@ -1081,10 +1081,10 @@ module ClassMethods # [collection.size] # Returns the number of associated objects. # [collection.find(...)] - # Finds an associated object according to the same rules as ActiveRecord::Base.find. + # Finds an associated object according to the same rules as ActiveRecord::Base.find. # [collection.exists?(...)] # Checks whether an associated object with the given conditions exists. - # Uses the same rules as ActiveRecord::Base.exists?. + # Uses the same rules as ActiveRecord::Base.exists?. # [collection.build(attributes = {}, ...)] # Returns one or more new objects of the collection type that have been instantiated # with +attributes+ and linked to this object through a foreign key, but have not yet @@ -1103,7 +1103,7 @@ module ClassMethods # # === Example # - # Example: A Firm class declares has_many :clients, which will add: + # A Firm class declares has_many :clients, which will add: # * Firm#clients (similar to Client.where(firm_id: id)) # * Firm#clients<< # * Firm#clients.delete @@ -1137,8 +1137,8 @@ module ClassMethods # Controls what happens to the associated objects when # their owner is destroyed. Note that these are implemented as # callbacks, and Rails executes callbacks in order. Therefore, other - # similar callbacks may affect the :dependent behavior, and the - # :dependent behavior may affect other callbacks. + # similar callbacks may affect the :dependent behavior, and the + # :dependent behavior may affect other callbacks. # # * :destroy causes all the associated objects to also be destroyed. # * :delete_all causes all the associated objects to be deleted directly from the database (so callbacks will not be executed). @@ -1184,8 +1184,8 @@ module ClassMethods # If true, always save the associated objects or destroy them if marked for destruction, # when saving the parent object. If false, never save or destroy the associated objects. # By default, only save associated objects that are new records. This option is implemented as a - # before_save callback. Because callbacks are run in the order they are defined, associated objects - # may need to be explicitly saved in any user-defined before_save callbacks. + # +before_save+ callback. Because callbacks are run in the order they are defined, associated objects + # may need to be explicitly saved in any user-defined +before_save+ callbacks. # # Note that accepts_nested_attributes_for sets :autosave to true. # [:inverse_of] @@ -1210,7 +1210,7 @@ def has_many(name, scope = nil, options = {}, &extension) # Specifies a one-to-one association with another class. This method should only be used # if the other class contains the foreign key. If the current class contains the foreign key, # then you should use +belongs_to+ instead. See also ActiveRecord::Associations::ClassMethods's overview - # on when to use has_one and when to use belongs_to. + # on when to use +has_one+ and when to use +belongs_to+. # # The following methods for retrieval and query of a single associated object will be added: # @@ -1378,7 +1378,7 @@ def has_one(name, scope = nil, options = {}) # class is created and decremented when it's destroyed. This requires that a column # named #{table_name}_count (such as +comments_count+ for a belonging Comment class) # is used on the associate class (such as a Post class) - that is the migration for - # #{table_name}_count is created on the associate class (such that Post.comments_count will + # #{table_name}_count is created on the associate class (such that Post.comments_count will # return the count cached, see note below). You can also specify a custom counter # cache column by providing a column name instead of a +true+/+false+ value to this # option (e.g., counter_cache: :my_custom_counter.) @@ -1460,7 +1460,7 @@ def belongs_to(name, scope = nil, options = {}) # [collection<<(object, ...)] # Adds one or more objects to the collection by creating associations in the join table # (collection.push and collection.concat are aliases to this method). - # Note that this operation instantly fires update sql without waiting for the save or update call on the + # Note that this operation instantly fires update SQL without waiting for the save or update call on the # parent object, unless the parent object is a new record. # [collection.delete(object, ...)] # Removes one or more objects from the collection by removing their associations from the join table. @@ -1483,10 +1483,10 @@ def belongs_to(name, scope = nil, options = {}) # [collection.find(id)] # Finds an associated object responding to the +id+ and that # meets the condition that it has to be associated with this object. - # Uses the same rules as ActiveRecord::Base.find. + # Uses the same rules as ActiveRecord::Base.find. # [collection.exists?(...)] # Checks whether an associated object with the given conditions exists. - # Uses the same rules as ActiveRecord::Base.exists?. + # Uses the same rules as ActiveRecord::Base.exists?. # [collection.build(attributes = {})] # Returns a new object of the collection type that has been instantiated # with +attributes+ and linked to this object through the join table, but has not yet been saved. diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index dc082b96f4828295a7c69081a34473e87ac0da6f..1f76adb3673b8c584d828d672b9b4df7a7539ac3 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -8,7 +8,7 @@ module Reflection # :nodoc: self.reflections = {} end - # Reflection enables to interrogate Active Record classes and objects + # \Reflection enables to interrogate Active Record classes and objects # about their associations and aggregations. This information can, # for example, be used in a form builder that takes an Active Record object # and creates input fields for all of the attributes depending on their type @@ -100,7 +100,7 @@ class MacroReflection # Returns the hash of options used for the macro. # # composed_of :balance, class_name: 'Money' returns { class_name: "Money" } - # has_many :clients returns +{}+ + # has_many :clients returns {} attr_reader :options attr_reader :active_record @@ -449,8 +449,8 @@ def valid_inverse_reflection?(reflection) # Checks to see if the reflection doesn't have any options that prevent # us from being able to guess the inverse automatically. First, the # +automatic_inverse_of+ option cannot be set to false. Second, we must - # have :has_many, :has_one, :belongs_to associations. Third, we must - # not have options such as :polymorphic or :foreign_key which prevent us + # have +has_many+, +has_one+, +belongs_to+ associations. Third, we must + # not have options such as +:polymorphic+ or +:foreign_key+ which prevent us # from correctly guessing the inverse association. # # Anything with a scope can additionally ruin our attempt at finding an