Using the (very nifty) attachment_fu plugin. It would be very convenient if I could batch-load a lot of my model objects that have attachments, instead of having to load them interactively via a web page. Experimented with calling uploaded_data= directly, but didn''t work, and I''m not sure that''s the right route. Any suggestions? Thanks, dwh --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Not sure if this is what you''re after or not. We have some scenarios in which we create files (reports) on the webserver in response to a user request and then save them on the server using an attachment_fu- based model. It''s similar in that we''re creating the model with a file but avoiding the interactive part. It was as simple as setting <model>.temp_path. Note that this works for us because we''re storing objects in the file system rather than the DB/S3. temp_path is mixed in for file system storage; not sure about the others. On May 5, 9:16 am, dwhsix <de...-QjqrIaraUJHsRQ7aLHQQZ6xOck334EZe@public.gmane.org> wrote:> Using the (very nifty) attachment_fu plugin. It would be very > convenient if I could batch-load a lot of my model objects that have > attachments, instead of having to load them interactively via a web > page. > > Experimented with calling uploaded_data= directly, but didn''t work, > and I''m not sure that''s the right route. Any suggestions? > > Thanks, > > dwh--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Denis Haskin
2008-May-05 15:05 UTC
Re: attachment_fu: loading objects w/ attachments in batch?
Hmm, that might work. Will investigate. Thanks, dwh AndyV wrote:> Not sure if this is what you''re after or not. We have some scenarios > in which we create files (reports) on the webserver in response to a > user request and then save them on the server using an attachment_fu- > based model. It''s similar in that we''re creating the model with a > file but avoiding the interactive part. > > It was as simple as setting <model>.temp_path. Note that this works > for us because we''re storing objects in the file system rather than > the DB/S3. temp_path is mixed in for file system storage; not sure > about the others. > > On May 5, 9:16 am, dwhsix <de...-QjqrIaraUJHsRQ7aLHQQZ6xOck334EZe@public.gmane.org> wrote: > >> Using the (very nifty) attachment_fu plugin. It would be very >> convenient if I could batch-load a lot of my model objects that have >> attachments, instead of having to load them interactively via a web >> page. >>--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Aha. http://blog.lachaise.org/?p=8 seems to provide a way to do this (in the middle of a discourse about duck typing...) dwh On May 5, 10:43 am, AndyV <AndyVana...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Not sure if this is what you''re after or not. We have some scenarios > in which we create files (reports) on the webserver in response to a > user request and then save them on the server using anattachment_fu- > based model. It''s similar in that we''re creating the model with a > file but avoiding the interactive part. > > It was as simple as setting <model>.temp_path. Note that this works > for us because we''re storing objects in the file system rather than > the DB/S3. temp_path is mixed in for file system storage; not sure > about the others.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Actually, having followed a suggestion in the comments to that blog entry, there''s even an easier way (below, ImageMetadata is my class that has_attachment): script/console>> Mime::Type.register "image/gif", :gif=> ["gif"]>> t = ActionController::TestUploadedFile.new(''db/seed-data//tile-samples/bippy2.gif'', Mime::GIF)=> #<ActionController::TestUploadedFile:0xb70358d8 @original_filename="bippy2.gif", @content_type=#<Mime::Type:0xb7039974 @synonyms=[], @symbol=:gif, @string="image/gif">, @tempfile=#<File:/ tmp/bippy214728-4.gif>>>> m = ImageMetadata.new=> #<ImageMetadata id: nil, size: nil, content_type: nil, filename: nil, height: nil, width: nil, parent_id: nil, thumbnail: nil, property_value_id: nil, created_at: nil, updated_at: nil>>> m.uploaded_data = t=> #<ActionController::TestUploadedFile:0xb70358d8 @original_filename="bippy2.gif", @content_type=#<Mime::Type:0xb7039974 @synonyms=[], @symbol=:gif, @string="image/gif">, @tempfile=#<File:/ tmp/bippy214728-4.gif>>>> m.save!=> true Seems like sorta a pain that you have to explicitly set the mime type, but hey, small price to pay... dwh On May 10, 9:50 pm, dwhsix <de...-QjqrIaraUJHsRQ7aLHQQZ6xOck334EZe@public.gmane.org> wrote:> Aha. http://blog.lachaise.org/?p=8seems to provide a way to do this > (in the middle of a discourse about duck typing...)--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---