Sha256: 9d425b48016c78cd315068ba362e244615a0bc79cb99a47fc9abf856bd0de371

Contents?: true

Size: 948 Bytes

Versions: 22

Compression:

Stored size: 948 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.scope.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

22 entries across 22 versions & 2 rubygems

Version Path
gaku_core-0.3.0 config/initializers/active_record.rb
gaku_core-0.3.0.pre.4 config/initializers/active_record.rb
gaku_core-0.3.0.pre.3 config/initializers/active_record.rb
gaku_core-0.3.0.pre.2 config/initializers/active_record.rb
gaku_core-0.3.0.pre.1 config/initializers/active_record.rb
gaku_core-0.3.0.pre.0 config/initializers/active_record.rb
gaku-0.2.4 core/config/initializers/active_record.rb
gaku_core-0.2.4 config/initializers/active_record.rb
gaku-0.2.3 core/config/initializers/active_record.rb
gaku_core-0.2.3 config/initializers/active_record.rb
gaku-0.2.2 core/config/initializers/active_record.rb
gaku_core-0.2.2 config/initializers/active_record.rb
gaku-0.2.1 core/config/initializers/active_record.rb
gaku_core-0.2.1 config/initializers/active_record.rb
gaku-0.2.0 core/config/initializers/active_record.rb
gaku_core-0.2.0 config/initializers/active_record.rb
gaku-0.1.1 core/config/initializers/active_record.rb
gaku_core-0.1.1 config/initializers/active_record.rb
gaku-0.1.0 core/config/initializers/active_record.rb
gaku_core-0.1.0 config/initializers/active_record.rb