Skip to content

Commit 77c0d7d

Browse files
committed
Changing the guides: explanation for ApplicationRecord.
1 parent 3761e53 commit 77c0d7d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

guides/source/active_record_basics.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,15 @@ p.name = "Some Book"
159159
puts p.name # "Some Book"
160160
```
161161

162+
Once you subclass `ApplicationRecord`, you get all of the functionality that is
163+
defined in the `ActiveRecord::Base` class since `ApplicationRecord` is itself a
164+
subclass of `ActiveRecord::Base`. The `ApplicationRecord` class allows you to
165+
configure Active Record without stepping over other applications that you would
166+
possibly be using, since every application you create has its own
167+
`ApplicationRecord`. Configurations set in `ActiveRecord::Base` are global to all
168+
applications using Active Record, but configurations set on `ApplicationRecord`
169+
are local to that application.
170+
162171
Overriding the Naming Conventions
163172
---------------------------------
164173

guides/source/getting_started.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,10 @@ There isn't much to this file - but note that the `Post` class inherits from
766766
`ApplicationRecord`. Active Record supplies a great deal of functionality to
767767
your Rails models for free, including basic database CRUD (Create, Read, Update,
768768
Destroy) operations, data validation, as well as sophisticated search support
769-
and the ability to relate multiple models to one another.
769+
and the ability to relate multiple models to one another. All you need to do
770+
to get all of this functionality is to subclass `ApplicationRecord` (which is
771+
itself a subclass of `ActiveRecord::Base` where all of the functionality is
772+
defined).
770773

771774
Rails includes methods to help you validate the data that you send to models.
772775
Open the `app/models/post.rb` file and edit it:

0 commit comments

Comments
 (0)