Class: EasySeeds::Destroy

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_seeds/destroy.rb

Class Method Summary collapse

Class Method Details

.destroy_table(class_name, table_string) ⇒ Object

For manually destroying tables, useful for if you have many joins tables.



4
5
6
7
8
# File 'lib/easy_seeds/destroy.rb', line 4

def self.destroy_table(class_name, table_string)
  puts "Destroying the #{table_string} table"
  class_name.destroy_all
  ApplicationRecord.connection.reset_pk_sequence!(table_string)
end

.destroy_tables(class_names, table_strings) ⇒ Object

Used in conjunction to destroy all of your tables



11
12
13
# File 'lib/easy_seeds/destroy.rb', line 11

def self.destroy_tables(class_names, table_strings)
  (class_names.length - 1).downto(0) {|i| Destroy.destroy_table(class_names[i], table_strings[i])}
end