-
-
Save andreif/1103815 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 | |
opts = '' | |
opts << ' --username ' << conn.username if conn.username rescue nil | |
opts << ' --password ' << conn.password if conn.password rescue nil | |
opts << ' --host ' << conn.host | |
opts << ' --port ' << conn.port.to_s | |
system "mongo #{opts} #{Mongoid.master.name}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://crumbtrail.chesmart.in/post/1334264255/handy-bits-for-mongoid-with-rails-3