Skip to content

Instantly share code, notes, and snippets.

@thoughtshop
Last active December 24, 2015 14:29
Show Gist options
  • Save thoughtshop/6813485 to your computer and use it in GitHub Desktop.
Save thoughtshop/6813485 to your computer and use it in GitHub Desktop.
module MultiTenantedCacheKeys
def cache_key
tenant_database_name + "/" + super
end
def tenant_database_name
Apartment::Database.current_database
end
end
class ActiveRecord::Base
def self.included(base)
if respond_to?(:cache_key)
raise NoMethodError.new("This object does not respond to #cache_key")
end
end
include MultiTenantedCacheKeys
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment