Sha256: 7aa6be27faad72d9aee1a88353dfb6da74d480bd3d6a74e118f1932117e119d0
Contents?: true
Size: 949 Bytes
Versions: 4
Compression:
Stored size: 949 Bytes
Contents
class ActiveRecord::Associations::HasManyThroughAssociation def insert_record(record, validate = true, raise = false) ensure_not_nested if record.new_record? if raise record.save!(validate: validate) else return unless record.save(validate: validate) end end save_through_record(record) #update_counter(1) record end def delete_records(records, method) ensure_not_nested scope = through_association.scoped.where(construct_join_attributes(*records)) case method when :destroy count = scope.destroy_all.length when :nullify count = scope.update_all(source_reflection.foreign_key => nil) else count = scope.delete_all end delete_through_records(records) if through_reflection.macro == :has_many && update_through_counter?(method) update_counter(-count, through_reflection) end #update_counter(-count) end end
Version data entries
4 entries across 4 versions & 2 rubygems