summaryrefslogtreecommitdiffstats
path: root/db/migrate/20130911193200_remove_eols_from_attachments_filename.rb
blob: d2f8281706d5359b0d8c994a21e5174588a19596 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
class RemoveEolsFromAttachmentsFilename < ActiveRecord::Migration
  def up
    Attachment.where("filename like ? or filename like ?", "%\r%", "%\n%").each do |attachment|
      filename = attachment.filename.to_s.tr("\r\n", "_")
      Attachment.where(:id => attachment.id).update_all(:filename => filename)
    end
  end

  def down
    # nop
  end
end