Skip to content

Instantly share code, notes, and snippets.

@cbeer
Created November 29, 2011 20:43
Show Gist options
  • Save cbeer/1406418 to your computer and use it in GitHub Desktop.
Save cbeer/1406418 to your computer and use it in GitHub Desktop.
Exclude models from the Rails identity map
require 'active_record/identity_map'
module ActiveRecord
module IdentityMap
class << self
alias_method :add_without_exclude, :add
def exclusions
@exclusions ||= []
end
def add(record)
return if self.exclusions.include? record.class
add_without_exclude(record)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment