delayed_paperclip
delayed_paperclip copied to clipboard
[Upgraded] For paperclip 3.1.2, with S3 fixes, and generic paperclip versions
Updated with my previous fixes to ensure it works on S3 too.
This is now working with paperclip 3.1.2, updated tests accordingly and gemfiles.
So in gemfile :
gem 'delayed_paperclip' , '2.4.5.2', :git => 'git://github.com/tommeier/delayed_paperclip', :branch => 'fix_312'
Good point @timols, i'll update now.
Removed unnecessary line and made sure a test checks the resulting value in case paperclip changes their API.
The redefinition of the most_appropriate_url doesn't work for me, it's still the original Paperclip::UrlGenerator one that is called. Also why not just creating a new UrlGenerator inheriting from Paperclip::UrlGenerator? You could just modify the default options to use it then. Here's what I did in my app:
module Paperclip
class MyUrlGenerator < UrlGenerator
def for(style_name, options)
escape_url_as_needed(
timestamp_as_needed(
@attachment_options[:interpolator].interpolate(most_appropriate_url(options), @attachment, style_name),
options
), options)
end
private
def most_appropriate_url(options)
if @attachment.original_filename.nil? || (!options[:without_processing] && @attachment.delayed_default_url?)
default_url
else
@attachment_options[:url]
end
end
end
end
And then in my model
Class Image < ActiveRecord::Base
has_attached_file(:resource, :url_generator => Paperclip::MyUrlGenerator, ... )
...
end
Oh, I also had another problem with your patch, you can't call reprocess!
directly anymore, it won't do anything, you need to call process_delayed!
. Maybe more a note than an issue as it's not something you want to call too often.
@bastien good idea, just want to work out a cleaner way to make it apply across the board when using delayed_paperclip, didn't have time to sort it out, so the quick hack won in the end unfortunately.
Calling reprocess! is working fine in prod for us?
@tommeier is it because you set the attachment post_processing to true
manually?