Created
October 17, 2010 05:45
-
-
Save ches/630581 to your computer and use it in GitHub Desktop.
Rake task to open MongoDB console for a Rails app with Mongoid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :db do | |
desc 'Open a MongoDB console with connection parameters for the current Rails.env' | |
task :console => :environment do | |
conn = Mongoid.master.connection | |
args = [] | |
args << "--username=#{conn.username}" if conn.username rescue nil | |
args << "--password=#{conn.password}" if conn.password rescue nil | |
args << "--host=#{conn.host}" | |
args << "--port=#{conn.port.to_s}" | |
args << Mongoid.master.name | |
exec 'mongo', *args | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Master/slave replication was replaced with replica sets. See my fork: https://gist.github.com/dwbutler/6372435