From cf05cf7af5de1ef3afcfb5d9b85eb7052bd0c0c2 Mon Sep 17 00:00:00 2001 From: lanzhiheng Date: Wed, 18 Jul 2018 17:35:04 +0800 Subject: [PATCH] Add situation for belongs to association. [ci skip] --- guides/source/association_basics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md index e7408b5a7f..67844ae7a4 100644 --- a/guides/source/association_basics.md +++ b/guides/source/association_basics.md @@ -96,7 +96,7 @@ end ![belongs_to Association Diagram](images/association_basics/belongs_to.png) -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. +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. The corresponding migration might look like this: