This repository has been archived by the owner on Oct 12, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from alphagov/add_tag
Create sub_category for tag_id of disabilities
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |