Created
June 5, 2015 16:21
-
-
Save ewalk153/8661b5e13792a62cccdd to your computer and use it in GitHub Desktop.
Console script to find bad paperclip image uploads and fix them.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def head_status(u) | |
uri = URI(u) | |
Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http| | |
request = Net::HTTP::Head.new uri | |
response = http.request request # Net::HTTPResponse object | |
response.code | |
end | |
end | |
UnitImage.all.select{|i| head_status(i.image.url('small')) == '403' }.each{|i| puts i }.map{|i| i.image.reprocess! } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment