mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add situation for belongs to association. [ci skip]
This commit is contained in:
parent
241bbf268c
commit
cf05cf7af5
1 changed files with 1 additions and 1 deletions
|
@ -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:
|
||||
|
||||
|
|
Loading…
Reference in a new issue