Class: EasySeeds::Destroy
- Inherits:
-
Object
- Object
- EasySeeds::Destroy
- Defined in:
- lib/easy_seeds/destroy.rb
Class Method Summary collapse
-
.destroy_table(class_name, table_string) ⇒ Object
For manually destroying tables, useful for if you have many joins tables.
-
.destroy_tables(class_names, table_strings) ⇒ Object
Used in conjunction to destroy all of your tables.
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 |