您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

20130911193200_remove_eols_from_attachments_filename.rb 359B

123456789101112
  1. class RemoveEolsFromAttachmentsFilename < ActiveRecord::Migration[4.2]
  2. def up
  3. Attachment.where("filename like ? or filename like ?", "%\r%", "%\n%").each do |attachment|
  4. filename = attachment.filename.to_s.tr("\r\n", "_")
  5. Attachment.where(:id => attachment.id).update_all(:filename => filename)
  6. end
  7. end
  8. def down
  9. # nop
  10. end
  11. end