Skip to content
This repository has been archived by the owner on Oct 12, 2018. It is now read-only.

Commit

Permalink
Merge pull request #31 from alphagov/add_tag
Browse files Browse the repository at this point in the history
Create sub_category for tag_id of disabilities
  • Loading branch information
alext committed Oct 15, 2012
2 parents 525e98b + d1e0bb5 commit 34e99b2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions 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

0 comments on commit 34e99b2

Please sign in to comment.