Hi, I have a migration which creates several records along with the table. eg Forum.create :title => "General Discussion", :description => "General Chit-Chat" But I''d like to create a record which accepts an uploaded file, such as a jpeg. Is it possible to automate this using the above technique? Thanks -- 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-/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 Tue, Jan 27, 2009 at 2:26 PM, Dan Smith <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi, > I have a migration which creates several records along with the table. > eg > Forum.create :title => "General Discussion", :description => "General > Chit-Chat" > > But I''d like to create a record which accepts an uploaded file, such as > a jpeg. Is it possible to automate this using the above technique? > > Thanks >How does your Forum model currently upload a file? Do you use an after_save callback to write the file into your file storage directory? Could you modify your callback to accept a filename from somewhere else in the filesystem and have it simply copy that file to your file storage directory? --wpd --~--~---------~--~----~------------~-------~--~----~ 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 have a migration which creates several records along with the table. > eg > Forum.create :title => "General Discussion", :description => "General > Chit-Chat"I am not sure you want to combine migrations with record creation. It is probably best for you to handle this via a load script or a rake task. As to the file upload, if you are using a plugin like attachment_fu, then you are all set. Take a look at the plugin tests directory to see how those simulate the upload of files and create the uploaded files either in the db or in the path you specified in your models. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---