From 91a393d20c7dcacf7a09e60da41af50705929c86 Mon Sep 17 00:00:00 2001 From: miteruzo Date: Tue, 22 Jul 2025 00:44:58 +0900 Subject: [PATCH] #83 --- backend/lib/tasks/link_nico.rake | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 backend/lib/tasks/link_nico.rake diff --git a/backend/lib/tasks/link_nico.rake b/backend/lib/tasks/link_nico.rake new file mode 100644 index 0000000..0c02f48 --- /dev/null +++ b/backend/lib/tasks/link_nico.rake @@ -0,0 +1,12 @@ +namespace :nico do + desc 'ニコタグ連携' + task link: :environment do + Post.find_each do |post| + tags = post.tags.where(category: 'nico') + tags.each do |tag| + post.tags.concat(tag.linked_tags) if tag.linked_tags.present? + end + post.tags = post.tags.to_a.uniq + end + end +end