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
#records_for(ids) ⇒ Object
Note:
Override to add sharding condition on preload
9 10 11 12 13 14 15 |
# File 'lib/active_record/turntable/active_record_ext/association_preloader.rb', line 9 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 |