diff --git a/app/models/application_record.rb b/app/models/application_record.rb index a70cb31c40..9d0f0cd422 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -3,10 +3,12 @@ class ApplicationRecord < ActiveRecord::Base include RedisCountable include Countable + include FakeSecondCache scope :recent, -> { order(id: :desc) } scope :exclude_ids, ->(ids) { where.not(id: ids.map(&:to_i)) } scope :by_week, -> { where("created_at > ?", 7.days.ago.utc) } delegate :url_helpers, to: "Rails.application.routes" + end diff --git a/app/models/concerns/fake_second_cache.rb b/app/models/concerns/fake_second_cache.rb new file mode 100644 index 0000000000..fc62088b79 --- /dev/null +++ b/app/models/concerns/fake_second_cache.rb @@ -0,0 +1,9 @@ +# Add a fake second_level_cache method to the model for compatibility with the Homeland plugins. +module FakeSecondCache + extend ActiveSupport::Concern + + class_methods do + def second_level_cache(args) + end + end +end diff --git a/test/support/model.rb b/test/support/model.rb index f43b7bcd7f..e99870dea6 100644 --- a/test/support/model.rb +++ b/test/support/model.rb @@ -1,4 +1,5 @@ class CommentablePage < ApplicationRecord + second_level_cache expires_in: 2.weeks end class Monkey < ApplicationRecord