Module: ParanoidFu::AssociationPreload

Defined in:
lib/paranoid_fu/association_preload.rb

Instance Method Summary collapse

Instance Method Details

#set_association_single_records(id_to_record_map, reflection_name, associated_records, key) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/paranoid_fu/association_preload.rb', line 3

def set_association_single_records(id_to_record_map, reflection_name, associated_records, key)
  reflection = reflect_on_association(reflection_name)
  # only it's needed to reject deleted records for polymorphic belongs_to, because in other case deleted records won't be loaded
  if reflection.options[:without_deleted] && reflection.options[:polymorphic]
    associated_records.delete_if {|item| item.class.paranoid? && item.deleted?}
  end
  super
end