Sha256: 4a8fdab8a7792047f6c270ff167e62d864c2d1569d1e62e43b45d1903c5321f7

Contents?: true

Size: 1.47 KB

Versions: 16

Compression:

Stored size: 1.47 KB

Contents

# encoding: utf-8
module Qbrick
  class AssetUploader < CarrierWave::Uploader::Base
    # Include RMagick or ImageScience support:
    include CarrierWave::MiniMagick
    # include CarrierWave::ImageScience

    # Choose what kind of storage to use for this uploader:
    storage :file
    # storage :s3

    # Override the directory where uploaded files will be stored.
    # This is a sensible default for uploaders that are meant to be mounted:
    def store_dir
      "uploads/#{mounted_as}/#{model.id}"
    end

    # Provide a default URL as a default if there hasn't been a file uploaded:
    # def default_url
    #   "/images/fallback/" + [version_name, "default.png"].compact.join('_')
    # end

    # Process files as they are uploaded:
    # process :scale => [200, 300]
    #
    # def scale(width, height)
    #   # do something
    # end

    # Create different versions of your uploaded files:
    version :thumb do
      process :resize_images
      def resize_images
        resize_to_fill(100, 100) if @file.present? && @file.content_type.present? &&
                                    @file.content_type.include?('image')
      end
    end

    # Add a white list of extensions which are allowed to be uploaded.
    # For images you might use something like this:
    def extension_white_list
      %w(jpg jpeg png pdf)
    end

    # Override the filename of the uploaded files:
    # def filename
    #   "something.jpg" if original_filename
    # end
    permissions 0600
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
qbrick-2.7.1 app/uploaders/qbrick/asset_uploader.rb
qbrick-2.7 app/uploaders/qbrick/asset_uploader.rb
qbrick-2.6.10 app/uploaders/qbrick/asset_uploader.rb
qbrick-2.6.9 app/uploaders/qbrick/asset_uploader.rb
qbrick-2.6.8 app/uploaders/qbrick/asset_uploader.rb
qbrick-2.6.7 app/uploaders/qbrick/asset_uploader.rb
qbrick-2.6.6 app/uploaders/qbrick/asset_uploader.rb
qbrick-2.6.5 app/uploaders/qbrick/asset_uploader.rb
qbrick-2.6.4 app/uploaders/qbrick/asset_uploader.rb
qbrick-2.6.3 app/uploaders/qbrick/asset_uploader.rb
qbrick-2.6.2 app/uploaders/qbrick/asset_uploader.rb
qbrick-2.6.1 app/uploaders/qbrick/asset_uploader.rb
qbrick-2.6.0 app/uploaders/qbrick/asset_uploader.rb
qbrick-2.5.2 app/uploaders/qbrick/asset_uploader.rb
qbrick-2.5.1 app/uploaders/qbrick/asset_uploader.rb
qbrick-2.5.0 app/uploaders/qbrick/asset_uploader.rb