Module: ActiveRecord::Turntable::ActiveRecordExt::AssociationPreloader

Extended by:
ActiveSupport::Concern
Defined in:
lib/active_record/turntable/active_record_ext/association_preloader.rb

Instance Method Summary collapse

Instance Method Details

#records_for_with_turntable(ids) ⇒ Object

Note:

Override to add sharding condition on preload



13
14
15
16
17
18
19
# File 'lib/active_record/turntable/active_record_ext/association_preloader.rb', line 13

def records_for_with_turntable(ids)
  returning_scope = records_for_without_turntable(ids)
  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