Class: DatabaseCleaner::ActiveRecord::Deletion

Inherits:
Truncation
  • Object
show all
Defined in:
lib/database_cleaner/active_record/deletion.rb

Instance Attribute Summary

Attributes included from Base

#connection_hash

Instance Method Summary collapse

Methods included from Generic::Truncation

#initialize, #start

Methods included from Base

#connection_class, #db, #db=, #load_config

Methods included from Generic::Base

#db, included

Instance Method Details

#cleanObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/database_cleaner/active_record/deletion.rb', line 10

def clean
  connection = connection_class.connection
  connection.disable_referential_integrity do
    sql = tables_to_truncate(connection).map do |table_name|
      "DELETE FROM #{connection.quote_table_name(table_name)}"
    end.join(";")

    connection.execute sql
  end
end