mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix unescaped '<' and badly formed ids on association_basics guide
This commit is contained in:
parent
cd9721791f
commit
78ab9beb49
1 changed files with 3 additions and 3 deletions
|
@ -417,7 +417,7 @@ h5. Creating Join Tables for +has_and_belongs_to_many+ Associations
|
|||
|
||||
If you create a +has_and_belongs_to_many+ association, you need to explicitly create the joining table. Unless the name of the join table is explicitly specified by using the +:join_table+ option, Active Record creates the name by using the lexical order of the class names. So a join between customer and order models will give the default join table name of "customers_orders" because "c" outranks "o" in lexical ordering.
|
||||
|
||||
WARNING: The precedence between model names is calculated using the +<+ operator for +String+. This means that if the strings are of different lengths, and the strings are equal when compared up to the shortest length, then the longer string is considered of higher lexical precedence than the shorter one. For example, one would expect the tables "paper_boxes" and "papers" to generate a join table name of "papers_paper_boxes" because of the length of the name "paper_boxes", but it in fact generates a join table name of "paper_boxes_papers" (because the underscore '_' is lexicographically _less_ than 's' in common encodings).
|
||||
WARNING: The precedence between model names is calculated using the +<+ operator for +String+. This means that if the strings are of different lengths, and the strings are equal when compared up to the shortest length, then the longer string is considered of higher lexical precedence than the shorter one. For example, one would expect the tables "paper_boxes" and "papers" to generate a join table name of "papers_paper_boxes" because of the length of the name "paper_boxes", but it in fact generates a join table name of "paper_boxes_papers" (because the underscore '_' is lexicographically _less_ than 's' in common encodings).
|
||||
|
||||
Whatever the name, you must manually generate the join table with an appropriate migration. For example, consider these associations:
|
||||
|
||||
|
@ -540,7 +540,7 @@ build_customer
|
|||
create_customer
|
||||
</ruby>
|
||||
|
||||
h6. _association_(force_reload = false)
|
||||
h6. association(force_reload = false)
|
||||
|
||||
The <tt><em>association</em></tt> method returns the associated object, if any. If no associated object is found, it returns +nil+.
|
||||
|
||||
|
@ -550,7 +550,7 @@ The <tt><em>association</em></tt> method returns the associated object, if any.
|
|||
|
||||
If the associated object has already been retrieved from the database for this object, the cached version will be returned. To override this behavior (and force a database read), pass +true+ as the +force_reload+ argument.
|
||||
|
||||
h6. _association_=(associate)
|
||||
h6. association=(associate)
|
||||
|
||||
The <tt><em>association</em>=</tt> method assigns an associated object to this object. Behind the scenes, this means extracting the primary key from the associate object and setting this object's foreign key to the same value.
|
||||
|
||||
|
|
Loading…
Reference in a new issue