Skip to content

Commit 5e55c80

Browse files
authored
Merge pull request rails#33384 from lanzhiheng/add-situation-for-belongs-to-associations-note
[ci skip] Add situation for belongs to association.
2 parents 371e375 + cf05cf7 commit 5e55c80

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

guides/source/association_basics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ end
9696

9797
![belongs_to Association Diagram](images/association_basics/belongs_to.png)
9898

99-
NOTE: `belongs_to` associations _must_ use the singular term. If you used the pluralized form in the above example for the `author` association in the `Book` model, you would be told that there was an "uninitialized constant Book::Authors". This is because Rails automatically infers the class name from the association name. If the association name is wrongly pluralized, then the inferred class will be wrongly pluralized too.
99+
NOTE: `belongs_to` associations _must_ use the singular term. If you used the pluralized form in the above example for the `author` association in the `Book` model and tried to create the instance by `Book.create(authors: @author)`, you would be told that there was an "uninitialized constant Book::Authors". This is because Rails automatically infers the class name from the association name. If the association name is wrongly pluralized, then the inferred class will be wrongly pluralized too.
100100

101101
The corresponding migration might look like this:
102102

0 commit comments

Comments
 (0)