Sha256: 201fe70388b01aeeb303fbfb4bde427ed369fd774f69f391e17f2f8221074fa1

Contents?: true

Size: 634 Bytes

Versions: 8

Compression:

Stored size: 634 Bytes

Contents

module C80Contest

  class ButtonPhotoUploader < ::CarrierWave::Uploader::Base

    include ::CarrierWave::MiniMagick

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

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

    def store_dir
      'uploads/buttons/'
    end

    def filename
      if original_filename
        "button_#{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

8 entries across 8 versions & 1 rubygems

Version Path
c80_contest-0.1.9 app/uploaders/c80_contest/button_photo_uploader.rb
c80_contest-0.1.8 app/uploaders/c80_contest/button_photo_uploader.rb
c80_contest-0.1.7 app/uploaders/c80_contest/button_photo_uploader.rb
c80_contest-0.1.6 app/uploaders/c80_contest/button_photo_uploader.rb
c80_contest-0.1.5 app/uploaders/c80_contest/button_photo_uploader.rb
c80_contest-0.1.4 app/uploaders/c80_contest/button_photo_uploader.rb
c80_contest-0.1.3 app/uploaders/c80_contest/button_photo_uploader.rb
c80_contest-0.1.2 app/uploaders/c80_contest/button_photo_uploader.rb