aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorGeorge Claghorn <george.claghorn@gmail.com>2018-07-22 10:42:05 -0400
committerGitHub <noreply@github.com>2018-07-22 10:42:05 -0400
commit020d942bb075b29318f83d69eabca86a84525347 (patch)
tree8e1ba941bce22ab5ea9d0f8a70b58e5f1dcdc431 /guides/source
parente0ee147e28e78f48c29c2a49ac725465814621be (diff)
parent063003f3f7ec10c018b5999eb877f61fcc8831be (diff)
downloadrails-020d942bb075b29318f83d69eabca86a84525347.tar.gz
rails-020d942bb075b29318f83d69eabca86a84525347.tar.bz2
rails-020d942bb075b29318f83d69eabca86a84525347.zip
Merge pull request #33416 from krmannix/master
[ci skip] fix typo in Active Record Associations guide
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/association_basics.md2
1 files changed, 1 insertions, 1 deletions
diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md
index 67844ae7a4..808aa9d691 100644
--- a/guides/source/association_basics.md
+++ b/guides/source/association_basics.md
@@ -600,7 +600,7 @@ NOTE: If you wish to [enforce referential integrity at the database level](/acti
#### 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 book of the class names. So a join between author and book models will give the default join table name of "authors_books" because "a" outranks "b" in lexical ordering.
+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 author and book models will give the default join table name of "authors_books" because "a" outranks "b" 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).