Sha256: e3be37a7c36ae56486db550a36c4485e34fbdb928617e523a891d1f95d8ef1d5

Contents?: true

Size: 642 Bytes

Versions: 5

Compression:

Stored size: 642 Bytes

Contents

module C80Contest

  class BidPhotoUploader < ::CarrierWave::Uploader::Base

    include ::CarrierWave::MiniMagick

    storage :file
    process :resize_to_limit => [1024,1024]

    version :thumb do
      process :resize_to_fit => [500,500]
    end

    def store_dir
      "#{Rails.root}/uploads/bids/"
    end

    def filename
      if original_filename
        "photo_#{secure_token(4)}.#{file.extension}"
      end
    end

    protected
    def secure_token(length=16)
      var = :"@#{mounted_as}_secure_token"
      model.instance_variable_get(var) or model.instance_variable_set(var, SecureRandom.hex(length/2))
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
c80_contest-0.1.9 app/uploaders/c80_contest/bid_photo_uploader.rb
c80_contest-0.1.8 app/uploaders/c80_contest/bid_photo_uploader.rb
c80_contest-0.1.7 app/uploaders/c80_contest/bid_photo_uploader.rb
c80_contest-0.1.6 app/uploaders/c80_contest/bid_photo_uploader.rb
c80_contest-0.1.5 app/uploaders/c80_contest/bid_photo_uploader.rb