Making Vlad copy database.yml to shared folder

Found this at http://topfunky.net/svn/shovel/merb/vlad_config.rb

Also good example of how to make vlad tasks.

# config/deploy.rb
# ... 
set :config_files, ['database.yml']

 namespace :vlad do

   desc "Copy config files from shared/config to release dir"
   remote_task :copy_config_files, :roles => :app do
     config_files.each do |filename|
       run "cp #{shared_path}/config/#{filename} #{release_path}/config/#{filename}"
     end
   end

   desc "Deploys"
   remote_task :deploy do
   end

   task :deploy => [:setup, :update, :copy_config_files, :migrate, :start]

 end
end

As you can see, I couldn’t find a way to make :copy_config_files be called after :update by just using

namespace :vlad
  task :update do
    Rake::Task[:copy_config_files].invoke
  end
end

so I ended up just creating an all-encompassing task, and that takes care of my needs at least for now. If you have any ideas on how to make this better, plesae pitch in.

2 Responses to “Making Vlad copy database.yml to shared folder”

  1. Bodaniel Jeanes Says:

    The reason you couldn’t make :copy_config_files get called after :update is because your Rake::Task line is wrong.

    Try:
    namespace :vlad
    task :update do
    Rake::Task["vlad:copy_config_files"].invoke
    end
    end

  2. Helder Says:

    Hey, that worked! I thought the task name for the #[] would also be escoped by namespace :vlad, but apparently it isn’t. Thanks a lot for the tip! :)


Leave a Reply