default_url is always hit with a HTTP request
Author: mrthankyouCreated Jun 21, 2021Updated Jun 21, 2021
Problem
Using Paperclip 6.1.0.
Whenever I save a model record that has a set image to it, the default_url is hit with a URL request. This is problematic if a developer who is locally testing data doesn't have access to the internet.
## model used
class Image < ActiveRecord::Base
PAPERCLIP_CONFIG = {
storage: :s3,
s3_protocol: :https,
bucket: 'xxx',
region: 'us-east-1',
s3_region: 'us-east-1',
s3_credentials: {
access_key_id: 'xxx',
secret_access_key: 'xxx'
},
path: ':class/:id/:basename.:extension'
}
has_attached_file :image_asset, PAPERCLIP_CONFIG.merge(
{
styles: {
small: ["152x198"],
large: ["500x700#"],
larger: ["616x732"],
},
path: ":class/:id/:style/:basename.:extension"
})
end
## code
image_path = Rails.root.join('app', 'assets', 'images', 'Default.jpg')
image_file = File.new(image_path)
image = Image.new(image_asset: image_file)
image.save!
What I Expect To Happen
If I'm creating a new image with a pre-determined asset, I shouldn't expect my default_url to be hit with a HTTP request.
Source: thoughtbot/paperclip