Macrow / rails_kindeditor

Kindeditor for Ruby on Rails
260 stars 108 forks source link

carrierwave v0.11.2 已经发布,Carrierwave::MimeType 要废弃了 #83

Closed bastengao closed 8 years ago

bastengao commented 8 years ago

asset_uploader.rb require 了 'carrierwave/processing/mime_types' 但是有没有在 AssetUploader 中 include Carrierwave::MimeType. https://github.com/Macrow/rails_kindeditor/blob/master/app/uploaders/kindeditor/asset_uploader.rb#L3

require 'carrierwave/processing/mime_types'

class Kindeditor::AssetUploader < CarrierWave::Uploader::Base
  # 没有 include , 所以上面 require 了也没用到
  # include CarrierWave::MimeTypes

  EXT_NAMES = {:image => RailsKindeditor.upload_image_ext,
               :flash => RailsKindeditor.upload_flash_ext,
               :media => RailsKindeditor.upload_media_ext,
               :file  => RailsKindeditor.upload_file_ext}

CarrierWave 可以直接使用 uploader.content_type, 提交在这里

我看唯一用到地方是 Assets model 里。

  def update_asset_attributes
    if asset.present? && asset_changed?
      self.file_size = asset.file.size
      self.file_type = asset.file.content_type
    end
  end

建议删掉 require 'carrierwave/processing/mime_types' 这行。

Macrow commented 8 years ago

删掉 require 'carrierwave/processing/mime_types' 后不影响使用吗?

bastengao commented 8 years ago

CarrierWave::Utilities::Deprecation.new "0.11.0", "CarrierWave::MimeTypes is deprecated and will be removed in the future, get the content_type from the SanitizedFile object directly."

https://github.com/carrierwaveuploader/carrierwave/blob/v0.11.2/lib/carrierwave/processing/mime_types.rb#L30