I’m running a web app that uploads images through paperclip, then performs image processing on them in an opencv-backed ruby extension gem, which requires a string path to run. The code I’ve been using is as follows:
imageFiles # => Array of ActiveRecord objects with attached paperclip files ('image')
filenames = Array.new()
imageFiles.each{ |imFile|
filenames.push( imFile.image.path )
}
imgproc = ImageProcessor.new # => extension
imgproc.process( filenames )
This gives me the following error:
can't convert Paperclip::Attachment into String
If I push:
imFile.image.file_name
Instead, my error becomes:
undefined method `file_name' for /xxx/xxx/xxx/000/000/062/original/img.jpg?1340296339:Paperclip::Attachment
Am I on the right path, or is there a step I’m missing? Thanks in advance!
Turns out that earlier I was pushing an image into the array of filenames instead of the files themselves, one of the dangers of ducktyped languages.