The code powering m.abunchtell.com https://m.abunchtell.com
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

20 行
631 B

  1. # frozen_string_literal: true
  2. require 'mime/types/columnar'
  3. module Paperclip
  4. class TypeCorrector < Paperclip::Processor
  5. def make
  6. target_extension = options[:format]
  7. extension = File.extname(attachment.instance.file_file_name)
  8. return @file unless options[:style] == :original && target_extension && extension != target_extension
  9. attachment.instance.file_content_type = options[:content_type] || attachment.instance.file_content_type
  10. attachment.instance.file_file_name = File.basename(attachment.instance.file_file_name, '.*') + '.' + target_extension
  11. @file
  12. end
  13. end
  14. end