Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Create sub_category for tag_id of disabilities

  • Loading branch information...
commit d1e0bb5b7c402f4580fe09ba992f2f3bdfab4591 1 parent 61b4cff
Mazz Mosley authored
Showing with 25 additions and 0 deletions.
  1. +25 −0 lib/tasks/add_disabled_sub_category.rake
View
25 lib/tasks/add_disabled_sub_category.rake
@@ -0,0 +1,25 @@
+# NOTE: This is to specifically create a disabilities sub category
+# then tag all content with disabilities with this new sub category
+
+namespace :migrate do
+ desc "Create sub category and tag all content with disabilities tag_id with new sub cat"
+ task :create_sub_category_and_tag => :environment do |t, args|
+ tag = Tag.where(tag_id: "disabilities").first
+ if tag.nil?
+ raise "Wa? No frakkin' tag with tag_id #{args[:tag_id]}"
+ end
+
+ sub_cat = Tag.new({tag_id: "disabilities/disabled-people",
+ parent_id: "disabilities", description: "Includes your rights, benefits and the Equality Act",
+ tag_type: "section", title: "Disabled people"})
+ sub_cat.save!
+ puts "Created: #{sub_cat.inspect}"
+
+ artefacts = Artefact.any_in(tag_ids: [tag.tag_id])
+ artefacts.each do |a|
+ a.tag_ids = a.tag_ids.append(sub_cat.tag_id)
+ puts "Updating #{a.slug} with #{a.tag_ids}"
+ a.save!
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.