Fix missing tagged_ids in some taggable objects and add a rake task for it

This commit is contained in:
chris committed 2013-07-18 14:05:21 +08:00
1 parent ceac2b842c
commit 3467868607
2 files changed
+13 -3

No files matched your search

+12
View File
@@ -310,4 +310,16 @@ namespace :migrate do
Rake::Task["web_link_url:web_link_url_i18n"].execute
end
task :fix_tagged_ids => :environment do
Tag.all.each do |tag|
tag.taggings.each do |tagging|
tagged_ids = tagging.taggable.tagged_ids
unless tagged_ids.include?(tag.id.to_s)
tagged_ids << tag.id.to_s
tagging.taggable.update_attribute(:tagged_ids, tagged_ids)
end
end
end
end
end