1

我正在尝试允许上传 pdf 文件。pdf 文件上传后,aPaperclip::Processor会在其 make 实例方法中将其转换为文本文件。然后,我想解析文本文件以填充ActiveRecord类。如何访问处理器在其 make 实例方法中返回的已处理文件?

代码骨架在这里:

module Paperclip
  class PdfToText < Processor
    ...
     def make
      dst = File.new(..)
      #do something to dst
      dst
     end
  end
end

class Xyz < ActiveRecord::Base
  has_attached_file :source_file, ..., :processors =>[:pdftotext]

  after_post_process :do_it

  def do_it
    # I would like to access the dst file returned in make of the processor PdfToText
  end
end

欣赏你的想法。

4

1 回答 1

1

那这个呢?

source_file.queued_for_write[:original].path
于 2012-07-06T11:24:28.007 回答