Skip to content

Instantly share code, notes, and snippets.

@voldy
Created February 12, 2012 13:18
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save voldy/1808418 to your computer and use it in GitHub Desktop.
Save voldy/1808418 to your computer and use it in GitHub Desktop.
Capistrano Mongoid recipes
# Use the config/mongoid/#{rails_env}.yml file for mongoid config
namespace :mongoid do
desc "Copy mongoid config"
task :copy do
upload "config/mongoid/#{rails_env}.yml", "#{shared_path}/mongoid.yml", :via => :scp
end
desc "Link the mongoid config in the release_path"
task :symlink do
run "test -f #{release_path}/config/mongoid.yml || ln -s #{shared_path}/mongoid.yml #{release_path}/config/mongoid.yml"
end
desc "Create MongoDB indexes"
task :index do
run "cd #{current_path} && #{bundle_cmd} exec rake db:mongoid:create_indexes", :once => true
end
end
after "deploy:update_code", "mongoid:copy"
after "deploy:update_code", "mongoid:symlink"
after "deploy:update", "mongoid:index"
@FunkyloverOne
Copy link

Hey @voldy! Could you please help me a bit with this code?
What does it exactly mean :once => true? As we actually need to create indexes on each deploy (it's like a migration).
Also is #{bundle_cmd} still relevant? Does it have a RAILS_ENV variable setting inside of it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment