Skip to content

Instantly share code, notes, and snippets.

@bradrobertson
Created April 14, 2013 16:26
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 bradrobertson/5383307 to your computer and use it in GitHub Desktop.
Save bradrobertson/5383307 to your computer and use it in GitHub Desktop.
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