Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

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