Created
December 27, 2012 23:18
-
-
Save anonymous/4393062 to your computer and use it in GitHub Desktop.
Dragonfly patch to fall back to a default image when the original is not found.
This file contains 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
if Rails.env.development? | |
module Dragonfly | |
module DataStorage | |
class FileDataStore | |
def retrieve(relative_path) | |
validate_uid!(relative_path) | |
path = absolute(relative_path) | |
pathname = Pathname.new(path) | |
if !pathname.exist? | |
pathname = Pathname.new('/path/to/default-image.jpg') | |
end | |
raise DataNotFound, "couldn't find file #{ENV['RAILS_ROOT']}" unless pathname.exist? | |
[ | |
pathname, | |
(store_meta ? retrieve_meta_data(path) : {}) | |
] | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment