aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/engines.md
diff options
context:
space:
mode:
authorGenadi Samokovarov <gsamokovarov@gmail.com>2015-12-12 14:25:00 +0100
committerGenadi Samokovarov <gsamokovarov@gmail.com>2015-12-16 10:30:09 +0100
commit2067fff9e38df4e37bdbfc021cd6bb0c2d393a2a (patch)
tree18c5067747cc422aed35dce0417f14ddf36346a7 /guides/source/engines.md
parente73fe1dd8c2740ae29e7a7f48d71a62b46e6b49d (diff)
downloadrails-2067fff9e38df4e37bdbfc021cd6bb0c2d393a2a.tar.gz
rails-2067fff9e38df4e37bdbfc021cd6bb0c2d393a2a.tar.bz2
rails-2067fff9e38df4e37bdbfc021cd6bb0c2d393a2a.zip
Introduce ApplicationRecord, an Active Record layer supertype
It's pretty common for folks to monkey patch `ActiveRecord::Base` to work around an issue or introduce extra functionality. Instead of shoving even more stuff in `ActiveRecord::Base`, `ApplicationRecord` can hold all those custom work the apps may need. Now, we don't wanna encourage all of the application models to inherit from `ActiveRecord::Base`, but we can encourage all the models that do, to inherit from `ApplicationRecord`. Newly generated applications have `app/models/application_record.rb` present by default. The model generators are smart enough to recognize that newly generated models have to inherit from `ApplicationRecord`, but only if it's present.
Diffstat (limited to 'guides/source/engines.md')
-rw-r--r--guides/source/engines.md10
1 files changed, 5 insertions, 5 deletions
diff --git a/guides/source/engines.md b/guides/source/engines.md
index a50ef9a95f..8382bde4d3 100644
--- a/guides/source/engines.md
+++ b/guides/source/engines.md
@@ -508,7 +508,7 @@ Turning the model into this:
```ruby
module Blorgh
- class Article < ActiveRecord::Base
+ class Article < ApplicationRecord
has_many :comments
end
end
@@ -1129,7 +1129,7 @@ end
```ruby
# Blorgh/app/models/article.rb
-class Article < ActiveRecord::Base
+class Article < ApplicationRecord
has_many :comments
end
```
@@ -1150,7 +1150,7 @@ end
```ruby
# Blorgh/app/models/article.rb
-class Article < ActiveRecord::Base
+class Article < ApplicationRecord
has_many :comments
def summary
"#{title}"
@@ -1171,7 +1171,7 @@ classes at run time allowing you to significantly modularize your code.
```ruby
# MyApp/app/models/blorgh/article.rb
-class Blorgh::Article < ActiveRecord::Base
+class Blorgh::Article < ApplicationRecord
include Blorgh::Concerns::Models::Article
def time_since_created
@@ -1187,7 +1187,7 @@ end
```ruby
# Blorgh/app/models/article.rb
-class Article < ActiveRecord::Base
+class Article < ApplicationRecord
include Blorgh::Concerns::Models::Article
end
```