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
class PaperclipGlobalReprocessor | |
def run | |
models.each do |model| | |
attachments = model.try(:attachment_definitions).try(:keys) | |
next unless attachments | |
model.find_each do |resource| | |
attachments.each do |attachment| | |
resource.send(attachment).reprocess! if resource.send(:"#{ attachment }?") |
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
#!/usr/bin/env ruby | |
# | |
# This script allows for parsing every models of your app, looking for string | |
# and text fields, then replacing every previous hardcoded URL with a new | |
# URL reflecting your new assets location | |
# | |
# Example usage : | |
# | |
# # Replace all URLs targeting an S3 bucket to a locale system URL | |
# rake replace_models_assets_url MATCHER="http://s3.amazonaws.com/mybucket/" REPLACEMENT="/system/" |