うーん、楽しい問題ではありません。私が考えることができる最も厄介な方法は、マイグレーションに、attachment-fu を介してすべてのファイルを実際に「アップロード」するコードを含めることです。これにより、プラグインが ID を作成してファイルを配置できるようになります。
このようなもの:
Dir.glob("/images/to/import/*.{jpg,png,gif}").each do |path|
# simulate uploading the image
tempfile = Tempfile.new(path)
tempfile.set_encoding(Encoding::BINARY) if tempfile.respond_to?(:set_encoding)
tempfile.binmode
FileUtils.copy_file(path, tempfile.path)
# create as you do in the controller - may need other metadata here
image = Image.create({:uploaded_data => tempfile})
unless image.save
logger.info "Failed to save image #{path} in migration: #{image.errors.full_messages}"
end
tempfile.close!
end
attachment-fu のテストを見ると役に立つかもしれません。