Skip to content

Commit 6d24876

Browse files
Merge pull request #55221 from duffuniverse/fix-typos-in-active-record-associations-guide
[ci skip] Fix typos in the Active Record Associations guide (cherry picked from commit 53a9a31)
1 parent 83b7f59 commit 6d24876

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

guides/source/association_basics.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ then you should use `has_one` instead.
217217

218218
When used alone, `belongs_to` produces a one-directional one-to-one
219219
relationship. Therefore each book in the above example "knows" its author, but
220-
the authors don't know about their books. To setup a [bi-directional
220+
the authors don't know about their books. To set up a [bi-directional
221221
association](#bi-directional-associations) - use `belongs_to` in combination
222222
with a `has_one` or `has_many` on the other model, in this case the Author
223223
model.
@@ -560,7 +560,7 @@ the associated object's foreign key to the same value.
560560

561561
The `build_association` method returns a new object of the associated type. This
562562
object will be instantiated from the passed attributes, and the link through
563-
this objects foreign key will be set, but the associated object will _not_ yet
563+
this object's foreign key will be set, but the associated object will _not_ yet
564564
be saved.
565565

566566
```ruby
@@ -1599,7 +1599,7 @@ Similarly, you can retrieve a collection of pictures from an instance of the
15991599
Additionally, if you have an instance of the `Picture` model, you can get its
16001600
parent via `@picture.imageable`, which could be an `Employee` or a `Product`.
16011601

1602-
To setup a polymorphic association manually you would need to declare both a
1602+
To set up a polymorphic association manually you would need to declare both a
16031603
foreign key column (`imageable_id`) and a type column (`imageable_type`) in the
16041604
model:
16051605

@@ -1869,7 +1869,7 @@ end
18691869
class Car < Vehicle
18701870
end
18711871

1872-
Car.create
1872+
Car.create(color: "Red", price: 10000)
18731873
# => #<Car kind: "Car", color: "Red", price: 10000>
18741874
```
18751875

@@ -1890,7 +1890,7 @@ class Vehicle < ApplicationRecord
18901890
self.inheritance_column = nil
18911891
end
18921892

1893-
Vehicle.create!(type: "Car")
1893+
Vehicle.create!(type: "Car", color: "Red", price: 10000)
18941894
# => #<Vehicle type: "Car", color: "Red", price: 10000>
18951895
```
18961896

@@ -1914,8 +1914,7 @@ includes all attributes of all subclasses in a single table.
19141914

19151915
A disadvantage of this approach is that it can result in table bloat, as the
19161916
table will include attributes specific to each subclass, even if they aren't
1917-
used by others. This can be solved by using [`Delegated
1918-
Types`](#delegated-types).
1917+
used by others. This can be solved by using [`Delegated Types`](#delegated-types).
19191918

19201919
Additionally, if you’re using [polymorphic
19211920
associations](#polymorphic-associations), where a model can belong to more than

0 commit comments

Comments
 (0)