attachment_fu File System Storage Change - Update?


It looks like one of the recent updates to attachment_fu has changed the way it names/stores files in the filesystem. I'm guessing it was this one:

* add default ID partitioning for attachments

Anyway, my files used to be stored in directories named after the PK. Now it seems that things have changed and files are stored with a new scheme.

So, anyone have any suggestions as to how I can migrate to the new storage setup? All the images in my app are broken.


Hah, sorry about that. If it makes you feel any better, I broke
Lighthouse too :slight_smile:

For now, you can just hack your model like so:

        def partitioned_path(*args)
          [attachment_path_id] + args

I did a manual migration looping through all the records and moving
them manually. This isn't the exact code, but something like this
should work.

class Avatar
  def old_full_filename(thumbnail = nil)
    file_system_path = (thumbnail ? thumbnail_class :
    File.join(RAILS_ROOT, file_system_path, attachment_path_id.to_s,

Avatar.find(:all).each do |av|
  next unless File.exist?(av.old_full_filename)
  File.move av.old_full_filename, av.full_filename