Last active
August 29, 2015 14:01
-
-
Save kevinmtrowbridge/ca3435054d22eb2d2ac1 to your computer and use it in GitHub Desktop.
delayed_paperclip invoke sweeper with paperclip after_post_process method
This file contains hidden or 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
# 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