Class: Image

Inherits:
Asset
  • Object
show all
Defined in:
app/models/image.rb

Instance Method Summary collapse

Instance Method Details

#find_dimensionsObject



13
14
15
16
17
18
19
20
# File 'app/models/image.rb', line 13

def find_dimensions
  temporary = attachment.queued_for_write[:original]
  filename = temporary.path unless temporary.nil?
  filename = attachment.path if filename.blank?
  geometry = Paperclip::Geometry.from_file(filename)
  self.attachment_width  = geometry.width
  self.attachment_height = geometry.height
end

#no_attachement_errorsObject

if there are errors from the plugin, then add a more meaningful message



23
24
25
26
27
28
29
30
# File 'app/models/image.rb', line 23

def no_attachement_errors
  unless attachment.errors.empty?
    # uncomment this to get rid of the less-than-useful interrim messages
    # errors.clear
    errors.add :attachment, "Paperclip returned errors for file '#{attachment_file_name}' - check ImageMagick installation or image source file."
    false
  end
end