KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Nov-10 14:04 UTC
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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 10-Nov-07, at 9:04 AM, KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> > 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. >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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Nov-11 13:45 UTC
Re: Migrations to load photos with attachment_fu?
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
On Nov 10, 8:49 am, Jodi Showers
<j...-BOB1p6JRLoAV+D8aMU/kSg@public.gmane.org>
wrote:> On 10-Nov-07, at 9:04 AM,
KathysK...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
>
>
>
> > 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.
>
> 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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
I just put this here since couldn''t find it anywhere else on the net: require "action_controller/test_process" def self.up ... end -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
test -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.