Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
IdentityCache with Apartment Excluded Models
# Broken Example
class Company < ActiveRecord::Base
include IdentityCache
cache_index :subdomain
end
Company.table_name = 'public.companies'
Company.fetch_by_subdomain('app')
# => SELECT id FROM companies WHERE subdomain = 'app' LIMIT 1
# Fix for Broken Example
class Company < ActiveRecord::Base
self.table_name = 'public.companies'
include IdentityCache
cache_index :subdomain
end
Company.fetch_by_subdomain('app')
# => SELECT id FROM public.companies WHERE subdomain = 'app' LIMIT 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.