osulyanov
9/11/2015 - 8:03 AM

Generate random file name and save old saved file names (CarrierWave FTP)

Generate random file name and save old saved file names (CarrierWave FTP)

  def filename
    if original_filename
      if model && model.read_attribute(mounted_as).present?
        model.read_attribute(mounted_as)
      else
        "#{SecureRandom.hex}.#{File.extname(file.filename)}"
      end
    end
  end