diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2015-12-17 12:16:07 +0100 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2015-12-17 12:16:07 +0100 |
commit | 1bfce3f29d958a14ca1502d3d36a9a2bc1de3734 (patch) | |
tree | c170df3f5d2886a669ad757af931a8bb515b0202 /guides/source/caching_with_rails.md | |
parent | 48f5cecdb03f697a710169ccef1885fcaca70788 (diff) | |
parent | 4f813a85d8919a83dd6fc019614f6aea7af7d5ae (diff) | |
download | rails-1bfce3f29d958a14ca1502d3d36a9a2bc1de3734.tar.gz rails-1bfce3f29d958a14ca1502d3d36a9a2bc1de3734.tar.bz2 rails-1bfce3f29d958a14ca1502d3d36a9a2bc1de3734.zip |
Merge pull request #22626 from gsamokovarov/appliation-record-documentation-fixes
Appliation record documentation fixes
Diffstat (limited to 'guides/source/caching_with_rails.md')
-rw-r--r-- | guides/source/caching_with_rails.md | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/guides/source/caching_with_rails.md b/guides/source/caching_with_rails.md index 9a56233e4a..3a1a1ccfe6 100644 --- a/guides/source/caching_with_rails.md +++ b/guides/source/caching_with_rails.md @@ -175,11 +175,11 @@ your app will serve stale data. To fix this, we tie the models together with the `touch` method: ```ruby -class Product < ActiveRecord::Base +class Product < ApplicationRecord has_many :games end -class Game < ActiveRecord::Base +class Game < ApplicationRecord belongs_to :product, touch: true end ``` @@ -284,7 +284,7 @@ The most efficient way to implement low-level caching is using the `Rails.cache. Consider the following example. An application has a `Product` model with an instance method that looks up the product’s price on a competing website. The data returned by this method would be perfect for low-level caching: ```ruby -class Product < ActiveRecord::Base +class Product < ApplicationRecord def competing_price Rails.cache.fetch("#{cache_key}/competing_price", expires_in: 12.hours) do Competitor::API.find_price(id) |