Skip to content

Commit 04bebd5

Browse files
wangjohnrafaelfranca
authored andcommitted
Changing the guides: explanation for ApplicationRecord.
1 parent d88afe4 commit 04bebd5

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
@@ -161,6 +161,15 @@ p.name = "Some Book"
161161
puts p.name # "Some Book"
162162
```
163163

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

guides/source/getting_started.md

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

9971000
Rails includes methods to help you validate the data that you send to models.
9981001
Open the `app/models/article.rb` file and edit it:

0 commit comments

Comments
 (0)