Module: ActiveRecord::Turntable::ActiveRecordExt::AssociationPreloader
- Includes:
- ShardingCondition
- Defined in:
- lib/active_record/turntable/active_record_ext/association_preloader.rb
Instance Method Summary collapse
Instance Method Details
#build_scope ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/active_record/turntable/active_record_ext/association_preloader.rb', line 8 def build_scope returning_scope = super if should_use_shard_key? returning_scope = returning_scope.where(klass.turntable_shard_key => owners.map(&foreign_shard_key.to_sym).uniq) end returning_scope end |
#records_for(ids) ⇒ Object
Note:
Override to add sharding condition on preload
18 19 20 21 22 23 24 |
# File 'lib/active_record/turntable/active_record_ext/association_preloader.rb', line 18 def records_for(ids) returning_scope = super if should_use_shard_key? returning_scope = returning_scope.where(klass.turntable_shard_key => owners.map(&foreign_shard_key.to_sym).uniq) end returning_scope end |