1 class Attachment < ActiveRecord::Base
4 has_attachment :processor => :rmagick
5 validates_as_attachment
6 after_attachment_saved do |record|
11 class SmallAttachment < Attachment
12 has_attachment :max_size => 1.kilobyte
15 class BigAttachment < Attachment
16 has_attachment :size => 1.megabyte..2.megabytes
19 class PdfAttachment < Attachment
20 has_attachment :content_type => 'pdf'
23 class DocAttachment < Attachment
24 has_attachment :content_type => %w(pdf doc txt)
27 class ImageAttachment < Attachment
28 has_attachment :content_type => :image, :resize_to => [50,50]
31 class ImageOrPdfAttachment < Attachment
32 has_attachment :content_type => ['pdf', :image], :resize_to => 'x50'
35 class ImageWithThumbsAttachment < Attachment
36 has_attachment :thumbnails => { :thumb => [50, 50], :geometry => 'x50' }, :resize_to => [55,55]
37 after_resize do |record, img|
38 record.aspect_ratio = img.columns.to_f / img.rows.to_f
42 class FileAttachment < ActiveRecord::Base
43 has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files', :processor => :rmagick
44 validates_as_attachment
47 class ImageFileAttachment < FileAttachment
48 has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files',
49 :content_type => :image, :resize_to => [50,50]
52 class ImageWithThumbsFileAttachment < FileAttachment
53 has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files',
54 :thumbnails => { :thumb => [50, 50], :geometry => 'x50' }, :resize_to => [55,55]
55 after_resize do |record, img|
56 record.aspect_ratio = img.columns.to_f / img.rows.to_f
60 class ImageWithThumbsClassFileAttachment < FileAttachment
61 # use file_system_path to test backwards compatibility
62 has_attachment :file_system_path => 'vendor/plugins/attachment_fu/test/files',
63 :thumbnails => { :thumb => [50, 50] }, :resize_to => [55,55],
64 :thumbnail_class => 'ImageThumbnail'
67 class ImageThumbnail < FileAttachment
68 has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files/thumbnails'
72 class OrphanAttachment < ActiveRecord::Base
73 has_attachment :processor => :rmagick
74 validates_as_attachment
77 # no filename, no size, no content_type
78 class MinimalAttachment < ActiveRecord::Base
79 has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files', :processor => :rmagick
80 validates_as_attachment
88 class ImageScienceAttachment < ActiveRecord::Base
89 has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files',
90 :processor => :image_science, :thumbnails => { :thumb => [50, 51], :geometry => '31>' }, :resize_to => 55
92 rescue MissingSourceFile
94 puts "no ImageScience"
98 class MiniMagickAttachment < ActiveRecord::Base
99 has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files',
100 :processor => :mini_magick, :thumbnails => { :thumb => [50, 51], :geometry => '31>' }, :resize_to => 55
102 rescue MissingSourceFile
104 puts "no Mini Magick"
108 class MiniMagickAttachment < ActiveRecord::Base
109 has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files',
110 :processor => :mini_magick, :thumbnails => { :thumb => [50, 51], :geometry => '31>' }, :resize_to => 55
112 rescue MissingSourceFile
116 class S3Attachment < ActiveRecord::Base
117 has_attachment :storage => :s3, :processor => :rmagick, :s3_config_path => File.join(File.dirname(__FILE__), '../amazon_s3.yml')
118 validates_as_attachment
121 class S3WithPathPrefixAttachment < S3Attachment
122 has_attachment :storage => :s3, :path_prefix => 'some/custom/path/prefix', :processor => :rmagick
123 validates_as_attachment
125 rescue Technoweenie::AttachmentFu::Backends::S3Backend::ConfigFileNotFoundError
126 puts "S3 error: #{$!}"