選択できるのは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