To upload the file and only create a thumbnail when possible you can add a version with conditional processing. Then create a method that checks for valid content types.

class FileUploader &lt; CarrierWave::Uploader::Base
  include CarrierWave::MiniMagick
  include CarrierWave::MimeTypes 

  version :thumb, if: :imageable? do 
    process resize_to_fill: [150,150]
    process convert: "jpg"
  end

  protected

  def imageable?(new_file)
    is_image = new_file.content_type.start_with? 'image'
    is_pdf = new_file.content_type.end_with? 'pdf'
    is_image || is_pdf
  end
end


With Carrierwave and minimagic can I test if the file is imageable?
Which is the best introductory textbook for Bayesian statistics?

One book per answer, please.
