Skip to content

Instantly share code, notes, and snippets.

@ritikesh
Last active July 2, 2020 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ritikesh/99e797610087b24ac49bbc61dd5d4335 to your computer and use it in GitHub Desktop.
Save ritikesh/99e797610087b24ac49bbc61dd5d4335 to your computer and use it in GitHub Desktop.
blog gists
class Tenant < ActiveRecord::Base
...
# associations
has_one :tenant_configs
delegate :locale, :timezone, :date_format, ..., to: :tenant_configs_from_cache
def tenant_configs_from_cache
Rails.cache.fetch(“tenant_configs:#{self.id}:#{self.tenant_configs.updated_at.to_i}”) { self.tenant_configs }
end
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment