0

I want validate the file content of a paperclip attachment (https://github.com/thoughtbot/paperclip).

My model:

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" abort with error message "No such file or directory". It there a way to get the correct file name?

Heiko
  • 394
  • 1
  • 4
  • 14
  • I believe validate happens before saving, therefore there is no file on the disk either. – MurifoX Jul 24 '12 at 19:29
  • What are the values of `package.path` and `original_filename`? If the file does exist, it may be that you are looking for it in the wrong directory. – fdsaas Jul 24 '12 at 19:30

0 Answers0