问题描述:

I'm using carrierwave (0.10.0) with Fog for S3 uploads.

Implementing simple uploader:

class AvatarUploader < CarrierWave::Uploader::Base

def default_url(*_args)

"#{Rails.configuration.cdn_url}/no-image.png"

end

def extension_white_list

%w(jpg jpeg gif png)

end

end

and mount it here

class User

include Mongoid::Document

field :name, type: String

mount_uploader :avatar, AvatarUploader

end

When Im trying to set remote image even if no image is presented it doesn't fallback to default_url and simulates generation of file in S3 which is actually not there.

Example:

u = User.find('1234567')

u.remote_avatar_url = 'http://non-existing-url.com/avatar.jpg'

u.save!

And when I access after reloading document

u.reload

u.avatar.url # output https://ourcdn.url/somebucket/avatar.jpg

But when access it in the browser it's showing 404.

Any ideas?

相关阅读:
Top