Further abstract caching for includes
This commit is contained in:
parent
356d3874eb
commit
a21bcac9e1
4 changed files with 22 additions and 2 deletions
15
app/models/concerns/cacheable.rb
Normal file
15
app/models/concerns/cacheable.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Cacheable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
||||
def cache_associated(*associations)
|
||||
@cache_associated = associations
|
||||
end
|
||||
end
|
||||
|
||||
included do
|
||||
scope :with_includes, -> { includes(@cache_associated) }
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue