Skip to content

Commit

Permalink
Fix second_level_cache method not found error. (#1440)
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee authored Oct 29, 2024
1 parent 8009037 commit 9085935
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions app/models/concerns/fake_second_cache.rb
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions test/support/model.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class CommentablePage < ApplicationRecord
second_level_cache expires_in: 2.weeks
end

class Monkey < ApplicationRecord
Expand Down

0 comments on commit 9085935

Please sign in to comment.