Ruby Question

How to use PaperClip to retrieve an image over HTTPS using RoR?

I have an application which stores and retrieves images from Amazons


In order to do that I'm using paperclip.

I use an SSL certification for my application and so require all calls to use HTTPS.

In order to get an image from Amazon
I do the following:

<div class="col-md-6 col-md-offset-3 shopHeader">
<img class="img-responsive center-block" widith="150px" height="100px" src=<%= @shop.image.url(:original, timestamp:false) %>>

And when the page loads calls an URL such as

Instead I need to use HTTPS by generating a link such as

However I'm receiving some warnings such as:

Mixed Content: The page at '' was loaded over HTTPS, but requested an insecure image ''. This content should also be served over HTTPS.

Is there any way to tell Paperclip or my application to use HTTPS calls to get these images?

Answer Source

theres an option for has_attached_file in your model that specifies the protocol to use

# app/models/shop.rb
has_attached_file :image,
                  storage: :s3,
                  s3_protocol: :https #specify the protocol as https

the documentation explains the various options

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download