FEATURE: Create a rake task for destroying categories

Created a rake task for destroying multiple categories along with any
subcategories and topics the belong to those categories.

Also created a rake task for listing all of your categories.

Refactored existing destroy rake tasks to use new logging method, that
allows for puts output in the console but prevents it from showing in
the specs.
This commit is contained in:
Blake Erickson
2019-07-17 12:44:14 -06:00
parent 98866ca043
commit 092eeb5ca3
4 changed files with 148 additions and 52 deletions
+8
View File
@@ -36,3 +36,11 @@ end
def print_status(current, max)
print "\r%9d / %d (%5.1f%%)" % [current, max, ((current.to_f / max.to_f) * 100).round(1)]
end
desc "Output a list of categories"
task "categories:list" => :environment do
categories = Category.pluck(:id, :slug, :parent_category_id)
categories.each do |c|
puts "id: #{c[0]}, slug: #{c[1]}, parent: #{c[2]}"
end
end