Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version extensions not working #2125

Closed
miguelpeniche opened this issue Feb 17, 2017 · 0 comments
Closed

Version extensions not working #2125

miguelpeniche opened this issue Feb 17, 2017 · 0 comments

Comments

@miguelpeniche
Copy link

miguelpeniche commented Feb 17, 2017

This both codes keeps uploading all images to S3 with .jpg extension, i am using rails (4.2.6), carrierwave (1.0.0), ruby 2.3.1, fog (1.38.0), fog-aws (1.1.0)

class UserAvatarUploader < CarrierWave::Uploader::Base

    include CarrierWave::MiniMagick

    version :large do
        process resize_to_fit: [ 600, 600 ], convert: :jpg
    end

    version :small do
        process resize_to_fill: [ 216, 216 ], convert: :jpg
    end

    version :thumb do
        process resize_to_fill: [ 80, 80 ], convert: :png
    end

    version :tiny do
        process resize_to_fill: [ 50, 50 ], convert: :png
    end

    def filename
        "#{secure_token}.#{file.extension}" if original_filename.present?
    end

    protected

    def secure_token
        var = :"@#{mounted_as}_secure_token"
        model.instance_variable_get(var) or model.instance_variable_set(var, SecureRandom.uuid)
    end

end
class UserAvatarUploader < CarrierWave::Uploader::Base

    include CarrierWave::MiniMagick

    version :large do
        process resize_to_fit: [ 600, 600 ], convert: :jpg
    end

    version :small do
        process resize_to_fill: [ 216, 216 ], convert: :jpg
    end

    version :thumb do
        process resize_to_fill: [ 80, 80 ], convert: :png
    end

    version :tiny do
        process resize_to_fill: [ 50, 50 ], convert: :png
    end

end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants