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
| def encode_hash(hashie) | |
| Hash[ | |
| hashie.collect do |k, v| | |
| if (v.is_a?(Hash)) | |
| [ k, encode_hash(v) ] | |
| elsif (v.respond_to?(:encoding)) | |
| [ k, v.dup.force_encoding('UTF-8').encode('UTF-16', {invalid: :replace, undef: :replace, replace: '?'}).encode('UTF-8') ] | |
| elsif (v.respond_to?(:to_utf8)) | |
| [ k, v.to_utf8 ] | |
| else |
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
| def merge_hash_recursively(first_hash, second_hash) | |
| first_hash.merge(second_hash) { |key, a_item, b_item| merge_hash_recursively(a_item, b_item) } | |
| end |
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
| require 'fileutils' | |
| class PaperclipCleaner | |
| class << self | |
| def clean(parent_resource_id) | |
| book_images = ImageModel.where(parent_resource_id: parent_resource_id).to_a | |
| images.each do |image_object| |
NewerOlder