I have an application I''m working on which allows me to upload files. The files are stored somewhere in the public directory so that they can be accessed directly. When I deploy an update with Capistrano, I ''lose'' the files because of the current symlink points to the new checked out version. Before I start working on a solution, has anyone else already solved this problem? Stephen Gerstacker --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Stephen, If you store your uploaded files in public/system they won''t get overwritten with every code update. Hammed On 10/4/06, Stephen Gerstacker <sgerstacker-qOfIXkuI2Z3elmxzKc6BS1aTQe2KTcn/@public.gmane.org> wrote:> > > I have an application I''m working on which allows me to upload files. The > files are stored somewhere in the public directory so that they can be > accessed directly. When I deploy an update with Capistrano, I ''lose'' the > files because of the current symlink points to the new checked out > version. > > Before I start working on a solution, has anyone else already solved this > problem? > > Stephen Gerstacker > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yup. put them in the shared dir, or any other dir outside of those releases dir. You can do this to your app like so: create a directory in the deploy_to/shared dir, let''s call it file_storage. Copy all your current files to this /shared/file_storage dir. now, remove the dir and create a symlink to it. Now, to make sure that dir gets symlinked everytime during a depoy, create a task called after_update_code. In it, symlink the dir, like so: desc "Tasks to execute after code update" task :after_update_code, :roles => [:app, :db] do # uploaded file record storage run "rm -Rf #{release_path}/file_storage" run "ln -s #{uploaded_files_path}/file_storage #{release_path}/file_storage" end The rm removes the symlink and the ln -s relinks it back. in this case, uploaded_files_path could be: deploy_to/shared/files or just a dir /upload on your server root. hope this helps. cheers! On 10/3/06, Stephen Gerstacker <sgerstacker-qOfIXkuI2Z3elmxzKc6BS1aTQe2KTcn/@public.gmane.org> wrote:> > I have an application I''m working on which allows me to upload files. The > files are stored somewhere in the public directory so that they can be > accessed directly. When I deploy an update with Capistrano, I ''lose'' the > files because of the current symlink points to the new checked out version. > > Before I start working on a solution, has anyone else already solved this > problem? > > Stephen Gerstacker > > > > > > >-- Charles Brian Quinn self-promotion: www.seebq.com highgroove studios: www.highgroove.com slingshot hosting: www.slingshothosting.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 -~----------~----~----~----~------~----~------~--~---
Thanks, that worked like a charm. Stephen Gerstacker -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Charles Brian Quinn Sent: Tuesday, October 03, 2006 22:44 To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Re: Capistrano and Uploaded Documents Yup. put them in the shared dir, or any other dir outside of those releases dir. You can do this to your app like so: create a directory in the deploy_to/shared dir, let''s call it file_storage. Copy all your current files to this /shared/file_storage dir. now, remove the dir and create a symlink to it. Now, to make sure that dir gets symlinked everytime during a depoy, create a task called after_update_code. In it, symlink the dir, like so: desc "Tasks to execute after code update" task :after_update_code, :roles => [:app, :db] do # uploaded file record storage run "rm -Rf #{release_path}/file_storage" run "ln -s #{uploaded_files_path}/file_storage #{release_path}/file_storage" end The rm removes the symlink and the ln -s relinks it back. in this case, uploaded_files_path could be: deploy_to/shared/files or just a dir /upload on your server root. hope this helps. cheers! On 10/3/06, Stephen Gerstacker <sgerstacker-qOfIXkuI2Z3elmxzKc6BS1aTQe2KTcn/@public.gmane.org> wrote:> > I have an application I''m working on which allows me to upload files. The > files are stored somewhere in the public directory so that they can be > accessed directly. When I deploy an update with Capistrano, I ''lose'' the > files because of the current symlink points to the new checked outversion.> > Before I start working on a solution, has anyone else already solved this > problem? > > Stephen Gerstacker > > > > > > >-- Charles Brian Quinn self-promotion: www.seebq.com highgroove studios: www.highgroove.com slingshot hosting: www.slingshothosting.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 -~----------~----~----~----~------~----~------~--~---