You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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