Skip to content

Instantly share code, notes, and snippets.

@tubbo
Last active August 29, 2015 14:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tubbo/438962ed7f5635b69380 to your computer and use it in GitHub Desktop.
Save tubbo/438962ed7f5635b69380 to your computer and use it in GitHub Desktop.
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