Ruby on rails 如何在使用多个附件进行打印前使用回形针?
我正试图用回形针在模型上添加第二个附件。我使用的是一个简单的缩略图处理器,如:Ruby on rails 如何在使用多个附件进行打印前使用回形针?,ruby-on-rails,paperclip,Ruby On Rails,Paperclip,我正试图用回形针在模型上添加第二个附件。我使用的是一个简单的缩略图处理器,如: has_attached_file :attachment, :styles => { :thumb => "100x100>" } has_attached_file :attachment2, :styles => { :thumb => "100x100>" } 我希望它不要为非图像类型创建缩略图,例如: before_post_process :is_image? def
has_attached_file :attachment, :styles => { :thumb => "100x100>" }
has_attached_file :attachment2, :styles => { :thumb => "100x100>" }
我希望它不要为非图像类型创建缩略图,例如:
before_post_process :is_image?
def is_image?
!(File.extname(attachment_file_name) =~ /\A.jpe?g|pjpeg|gif|x-png|png\Z/i).nil?
end
对于第二个附件,我该怎么做?问题是对附件2文件名的引用,第二个文件名必须是附件2文件名。似乎可以这样写:
before_attachment_post_process :is_image?
before_attachment2_post_process :is_image2?