Has anyone had any success using Rick O.'s “attachment_fu” plugin
while developing on a Windows machine?
I’ve been looking for solutions to the issue described here
RailsNotes — The Ruby on Rails guides you wished you had. but haven’t heard anything
yet.
The issue is that attachment_fu fails to record the uploaded file’s size
value properly, causing its validations to fail.
I’ve been adding logger messages into the attachment_fu code to see
what’s causing my problems on Windows. In my case it’s not properly
assigning the “size†attribute.
In “attachment_fu.rbâ€, there is the following method:
def set_size_from_temp_path
self.size = File.size(temp_path) if save_attachment?
end
Based on logger messages, I’ve determined that save_attachment? returns
true, the temporary file does exist on my system, but that file’s
File.size parameter returns zero, so it saves self.size as zero, thus
failing the validations.
In my case, the uploaded_data IS properly assigned, and the image is
saved to the disk in the appropriate place. The only problem I’ve found
is with the size parameter. To complicate matters, the behavior is not
consistent. Occasionally it saves a size value, but most of the time the
size is zero.
I’ve created a brand new Rails app and model which uses only
attachment_fu’s required fields to test these conclusions.
On my system I’m using:
- Rails 1.2.2
- Windows XP
- MySQL 5.0
- ImageMagick-6.3.2-Q16
- mini_magick 1.2.0
When attachment_fu creates thumbnails, the thumbnail files ARE saved
with the correct size in their model. I don’t know why the original
files aren’t.
Does this have to do with Windows “Tempfile†issues? I tried out a
“windows_tempfile_fix†plugin but it required Ruby 1.8.4 where I have
1.8.5.
Does anyone have any ideas? Thanks,
Jeff