Sha256: 14ac7d82869c53ff0b08c4878a3537a9d24bcca0ff25ac65cc14a0e25dacae35
Contents?: true
Size: 1.4 KB
Versions: 9
Compression:
Stored size: 1.4 KB
Contents
class Upload < Asset default_scope where(:type => "Upload") validate :no_attachement_errors # Check for spree_heroku # https://github.com/paxer/spree-heroku # if defined?(SpreeHeroku) has_attached_file :attachment, :styles => Proc.new{ |clip| clip.instance.attachment_sizes }, :default_style => :medium, :path => "assets/uploads/:id/:style/:basename.:extension", :storage => "s3", :s3_credentials => "#{Rails.root}/config/s3.yml" else has_attached_file :attachment, :styles => Proc.new{ |clip| clip.instance.attachment_sizes }, :default_style => :medium, :url => "/assets/uploads/:id/:style/:basename.:extension", :path => ":rails_root/public/assets/uploads/:id/:style/:basename.:extension" end def image_content? attachment_content_type.match(/\/(jpeg|png|gif|tiff|x-photoshop)/) end def attachment_sizes if image_content? { :mini => '48x48>', :small => '150x150>', :medium => '420x300>', :large => '800x500>' } else {} end end def no_attachement_errors if attachment_file_name.blank? || !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 end
Version data entries
9 entries across 9 versions & 1 rubygems