处理导入题库标题中的换行字符

This commit is contained in:
guange 2016-02-02 21:28:52 +08:00
parent eb3644a197
commit 1f7bcbed20
1 changed files with 14 additions and 0 deletions

14
lib/tasks/import_fix.rake Normal file
View File

@ -0,0 +1,14 @@
namespace :import do
desc "fix import name"
task :fix => :environment do
HomeworkCommon.find_each do |homework|
name = homework.name.sub("\n", " ").sub("\r\n", " ")
if name != homework.name
homework.name = name
homework.save!
end
end
end
end