has attachment_fu changed recently?

Forums > Book - Chapter 7 > has attachment_fu changed recently?

Login to post a new topic

Author Message
jjkiesch
Member since 22 Jul 23:52
0 posts

i was having problems getting some of photo unit tests in the book to pass. i soon discovered that the uploaded directories were different in a different format. the attachment_fu plugin currently padds the id of the object to 8 digits and then splits it into separate folders by 4 characters. so a photo with the id of 1 is put in photos/0000/0001/myfile.jpg
fixing it was pretty easy once i figured out what was going on. i just changed file = File.join(RAILS_ROOT, ‘public’, ‘photos’, photo_id, ”#{image_file}”) to file = File.join(RAILS_ROOT, ‘public’, ‘photos’, (“%08d” % photo_id).scan(/..../), ”#{image_file}”) and everything works fine. i’m guessing that at the time of writing attachment_fu just used ids for the file folders instead of padding it out like that?

juanpaco
Member since 16 Mar 19:15
0 posts

1 Million thanks to you! The copy/paste introduced some odd characters, but that was easily resolved.

jimp
Member since 22 Sep 22:18
0 posts

Hi,
I just spent three full days trying to figure this one out, thought I had made a mistake, but it sounds like you have figured it out, and the problem is attachment fu.
Is it possible to roll back the version of attachment fu?
What version is compatible to the code in the book?
Alternately, where does the patch you indicate here go in the program? Which file? What does it replace?
Thanks!!
Jim Pickrell – Santa Monica, California

jimp
Member since 22 Sep 22:18
0 posts

Here’s a possible solution to make the program behave as described in the book:
http://the.railsi.st/2007/8/21/how-to-customize-attachment_fu-file-names
I’m still trying to figure this out but it looks like it should work…....