I need some help. I (finally) have an app setup for capistrano deployment. The only issue is that the admin interface allows uploads of some file to the public directory. When capistrano does a deploy, I get a brand new public directory, wiping out all the uploaded files. I am sure other have ran into this before, there must be a solution. I thought about putting all the uploaded file in the same spot, but the uploads have different purposes in multiple areas and would be awkward to simply group them into some articficial "uploads" directory that gets symlinked in. Any ideas? -- 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 -~----------~----~----~----~------~----~------~--~---
Charles Brian Quinn
2007-Jan-05 21:39 UTC
Re: Capistrano and uploads to the public directory
You''ll want to create a shared dir in the system/shared directory capistrano sets up for you. You can add this directory and make use of capistrano''s callback, the after_update_code which runs after it checks out a new release into the releases dir to re-link this every time. You can do something like this: desc "Tasks to execute after code update" task :after_update_code, :roles => [:app, :db] do # relink a shared public directory run "ln -nfs #{deploy_to}/#{shared_dir}/uploads #{release_path}/public/uploads" end That way you now have a symlink similar to how it handles your log directory. Hope that helps, -- Charles Brian Quinn self-promotion: www.seebq.com highgroove studios: www.highgroove.com slingshot hosting: www.slingshothosting.com Ruby on Rails Bootcamp at the Big Nerd Ranch Intensive Ruby on Rails Training: http://www.bignerdranch.com/classes/ruby.shtml On 1/5/07, Alex Wayne <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I need some help. I (finally) have an app setup for capistrano > deployment. The only issue is that the admin interface allows uploads > of some file to the public directory. > > When capistrano does a deploy, I get a brand new public directory, > wiping out all the uploaded files. > > I am sure other have ran into this before, there must be a solution. I > thought about putting all the uploaded file in the same spot, but the > uploads have different purposes in multiple areas and would be awkward > to simply group them into some articficial "uploads" directory that gets > symlinked in. > > Any ideas? > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Capistrano automatically creates a symlink: RAILS_ROOT/public/system -> RAILS_ROOT/../shared/system To build on this, I add symlinks to the repo, so in this case: RAILS_ROOT/public/uploads -> RAILS_ROOT/public/system/uploads I them set svn:ignore on public to ignore ''system'', and create a non- svn controlled directory in the working copy, in this case: mkdir -p RAILS_ROOT/public/system/uploads I find this more convenient, reliable, and traceable than creating symlinks on-the-fly via Capistrano. Charles'' method is also perfectly reasonable. -- -- Tom Mornini, CTO -- Engine Yard, Ruby on Rails Hosting -- Reliability, Ease of Use, Scalability -- (866) 518-YARD (9273) On Jan 5, 2007, at 1:39 PM, Charles Brian Quinn wrote:> You''ll want to create a shared dir in the system/shared directory > capistrano sets up for you. > > You can add this directory and make use of capistrano''s callback, the > after_update_code which runs after it checks out a new release into > the releases dir to re-link this every time. > > You can do something like this: > > desc "Tasks to execute after code update" > task :after_update_code, :roles => [:app, :db] do > > # relink a shared public directory > run "ln -nfs #{deploy_to}/#{shared_dir}/uploads > #{release_path}/public/uploads" > end > > That way you now have a symlink similar to how it handles your log > directory. > > Hope that helps, > > -- > Charles Brian Quinn > self-promotion: www.seebq.com > highgroove studios: www.highgroove.com > slingshot hosting: www.slingshothosting.com > > Ruby on Rails Bootcamp at the Big Nerd Ranch > Intensive Ruby on Rails Training: > http://www.bignerdranch.com/classes/ruby.shtml > > On 1/5/07, Alex Wayne <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> >> I need some help. I (finally) have an app setup for capistrano >> deployment. The only issue is that the admin interface allows >> uploads >> of some file to the public directory. >> >> When capistrano does a deploy, I get a brand new public directory, >> wiping out all the uploaded files. >> >> I am sure other have ran into this before, there must be a >> solution. I >> thought about putting all the uploaded file in the same spot, but the >> uploads have different purposes in multiple areas and would be >> awkward >> to simply group them into some articficial "uploads" directory >> that gets >> symlinked in. >> >> Any ideas? >> >> -- >> 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 -~----------~----~----~----~------~----~------~--~---
Mitchell Hashimoto
2007-Jan-06 08:35 UTC
Re: Capistrano and uploads to the public directory
Well, I recommend creating a directory called "uploads" in your "shared" folder in your capistrano directory and uploading them there. If you allow people to upload directly to your released app''s public directory, then when you deploy a new revision, all those uploads will be archived. If you instead upload them to the shared folder, you can use custom routes to display them using send_file. Because you said they have different purposes in multiple areas, I see the format like this: :area/:file For a simple one. You can forward that route to a controller which will then load the data from the shared folder, and use send_file to send it directly to the browser, as if that file were really located at the requsted URL. Alex Wayne wrote:> I need some help. I (finally) have an app setup for capistrano > deployment. The only issue is that the admin interface allows uploads > of some file to the public directory. > > When capistrano does a deploy, I get a brand new public directory, > wiping out all the uploaded files. > > I am sure other have ran into this before, there must be a solution. I > thought about putting all the uploaded file in the same spot, but the > uploads have different purposes in multiple areas and would be awkward > to simply group them into some articficial "uploads" directory that gets > symlinked in. > > Any ideas?-- 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 -~----------~----~----~----~------~----~------~--~---