Migrations to load photos with attachment_fu?

I've been studying the web this morning and trying to find examples where someone has imported photo 'test data' using attachment_fu? I've tried this in many was using a traditional data migration like I've done hundreds of times and nothing comes in? Attachment_fu put a record to the database, but there is so supporting file behind it. I enclose what my migration looks like for one record.

newrecord = Vendphoto.create( :vendor_id => '1', :title => 'Add Test Vendphoto 1', :content_type => 'image/jpeg', :size => '38414', :width => '230', :height => '200', :geo_lat => '27.9686', :geo_long => '-97.0943', :filename => 'KathyTest.jpg') newrecord.save! I 'presumed' some of this information by manually adding a photo and then looking at the MySQL record that was created. I experimented putting the photo in question 'KathyTest.jpg' in the \public\images and many other places. I load the 'Vendphoto' record in the database BUT the actual photo doesn't exist in my \Public\Images\Vendphoto (as if I had done this manuall). Thank you, Kathy KathysKode@gmail.com

here's an example of loading images in a migration.

     filename = "#{some_path}some_file.gif"      image = Image.create(:uploaded_data => ActionController::TestUploadedFile.new(filename, 'image/gif'))

the trick is using the ActionController:TestUploadFile to simulate a file upload request.

Cheers, Jodi

Jodi, I'm so excited about having the ability to load photos with migrations! Thank you for responding. I took your code and modified my original routine as shown:

  def self.up     down     filename = "#{'c:/temp/'}MollyTest.gif"     newrecord = Ephoto.create(       :uploaded_data => ActionController::TestUploadedFile.new(filename, 'image/gif'),       :eitem_id => '1',       :title => 'Add Test Ephoto 1',       :size => '1536',       :width => '100',       :height => '69',       :geo_lat => '27.9686',       :geo_long => '-97.0943')     newrecord.save!   end

The problem is a I get a "rake aborted! uninitialized constant ActionController::TestUploadedFile " message when I try to run the migration. Any suggestions are greatly appreciated. Kathleen

I just put this here since couldn't find it anywhere else on the net:

require "action_controller/test_process"

def self.up   ... end

test