Rails,Paperclip;验证附件

时间:2012-07-24 19:13:13

标签: ruby-on-rails paperclip paperclip-validation

我想验证回形针附件的文件内容(https://github.com/thoughtbot/paperclip)。

我的模特:

class PackageArchive < ActiveRecord::Base
  attr_accessible :package
  has_attached_file :package

  validates_attachment :package,
            :presence => true
  validate :open

  def open
    Rails.logger.debug "####" + original_filename.inspect
    file_content = `cat "#{package.path}"`
  end
end

“cat”中止,错误消息“没有这样的文件或目录”。有没有办法获得正确的文件名?

0 个答案:

没有答案