Add task to flatten category and tag for page and page_part

This commit is contained in:
chris 2013-03-21 14:15:58 +08:00
parent d01968dcd0
commit ee8a78621a
1 changed files with 13 additions and 0 deletions

View File

@ -209,6 +209,19 @@ namespace :migrate do
end end
end end
task :flatten_category_and_tag => :environment do
[Page,PagePart].each do |obj|
obj.all.each do |pp|
unless pp.category.blank?
pp.update_attribute(:category, pp.category.flatten)
end
unless pp.tag.blank?
pp.update_attribute(:tag, pp.tag.flatten)
end
end
end
end
task :clean_parts => :environment do task :clean_parts => :environment do
PagePart.where(widget_style: /\d/, kind: 'module_widget').each{|part| part.update_attributes({kind: 'text', widget_style: nil, widget_field: nil})} PagePart.where(widget_style: /\d/, kind: 'module_widget').each{|part| part.update_attributes({kind: 'text', widget_style: nil, widget_field: nil})}
PagePart.where(widget_style: /\d/).each{|part| part.update_attributes({widget_style: nil, widget_field: nil})} PagePart.where(widget_style: /\d/).each{|part| part.update_attributes({widget_style: nil, widget_field: nil})}