我正在尝试使用回形针向模型添加第二个附件。我正在使用一个简单的缩略图处理器,例如:
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
我如何为第二个附件执行此操作?问题是对 attachment_file_name 的引用,第二个需要是 attachment2_file_name。
最佳答案
似乎可以这样写:
before_attachment_post_process :is_image?
before_attachment2_post_process :is_image2?
关于ruby-on-rails - 如何将回形针 before_post_process 与多个附件一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19640603/