Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何在使用多个附件进行打印前使用回形针?_Ruby On Rails_Paperclip - Fatal编程技术网

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?