Sha256: 5c1881d96570493a7812ea9471d4c58cef6d81309ac261f06077b6ebf1040d11
Contents?: true
Size: 748 Bytes
Versions: 1
Compression:
Stored size: 748 Bytes
Contents
require "active_record/associations" module ActiveRecord::Turntable module ActiveRecordExt module Association include ShardingCondition def self.prepended(mod) ActiveRecord::Associations::Builder::Association.valid_options << :foreign_shard_key end protected # @note Override to pass shard key conditions def target_scope return super unless should_use_shard_key? scope = klass.where( klass.turntable_shard_key => owner.send(foreign_shard_key) ) super.merge!(scope) end private def skip_statement_cache? super || should_use_shard_key? end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activerecord-turntable-2.5.0 | lib/active_record/turntable/active_record_ext/association.rb |