Skip to content

Instantly share code, notes, and snippets.

@kevinmtrowbridge
Last active August 29, 2015 14:01
Show Gist options
  • Save kevinmtrowbridge/ca3435054d22eb2d2ac1 to your computer and use it in GitHub Desktop.
Save kevinmtrowbridge/ca3435054d22eb2d2ac1 to your computer and use it in GitHub Desktop.
delayed_paperclip invoke sweeper with paperclip after_post_process method
# http://stackoverflow.com/questions/14300427/how-do-i-add-a-model-specific-configuration-option-to-a-rails-concern
module HasDelayedPaperclip
extend ActiveSupport::Concern
module ActiveRecord
def custom_process_in_background(name, options = {})
process_in_background(name, options)
include HasDelayedPaperclip
after_post_process :clear_cache
end
end
module ClassMethods
# nothing yet
end
module InstanceMethods
def clear_cache
# http://pjkh.com/articles/manually-invoking-a-rails-sweeper/
sweeper_class = (self.class.to_s + 'Sweeper').constantize
sweeper_class.instance.after_save(self)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment