Last active
          December 24, 2015 14:29 
        
      - 
      
- 
        Save thoughtshop/6813485 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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