class Screenshot < ActiveRecord::Base belongs_to :package, :inverse_of=>:screenshots default_scope { order('uploaddatetime DESC') } has_attached_file :image, styles: { :large => "800x600>", :thumb => "160x120>" }, default_url: "/images/dummy/no-screenshots-upload-one.svg" #path: :rails_root/public/system/:class/:attachment/:id_partition/:style/:filename validates_attachment_content_type :image, :content_type => /\Aimage\/png\Z/ # Return caption for full-screen screenshots. # Takes the description of a screenshot if available. # Otherwise it falls back to the general description of its package. def caption if self.description != '' self.description else self.package.description end end end end end end