Last active
August 29, 2015 14:01
-
-
Save tubbo/438962ed7f5635b69380 to your computer and use it in GitHub Desktop.
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
class Image < AR::Base | |
validates :src, presence: true | |
validate :set_status_to_missing_url, :if => lambda { src.blank? } | |
def process | |
@logo_image = RmagickHelper.new self.src | |
rescue Magick::ImageMagickError => ex | |
logger.error "ImageMagick can not process the image: #{ex.message}" | |
ex.backtrace.each { |line| logger.debug line } | |
@logo_status = 'cant_process' | |
end | |
private | |
def set_status_to_missing_url | |
self.status = 'missing_url' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment