Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

default_url is always hit with a HTTP request #2691

Open
mrthankyou opened this issue Jun 21, 2021 · 0 comments
Open

default_url is always hit with a HTTP request #2691

mrthankyou opened this issue Jun 21, 2021 · 0 comments

Comments

@mrthankyou
Copy link

mrthankyou commented 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.

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

No branches or pull requests

1 participant