cirandas.net

ref: master

config/initializers/image_uploads.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
if File.writable?(Rails.root)
  misplaced_directories = Dir.glob(Rails.root.join('public/images/[0-9]*'))
  unless misplaced_directories.empty?
    new_location = Rails.root.join('public/image_uploads')
    if !File.exists?(new_location)
      FileUtils.mkdir(new_location)
    end
    misplaced_directories.each do |path|
      FileUtils.mv(path, new_location)
    end
  end
end