Last active
August 29, 2015 13:56
-
-
Save statonjr/9234483 to your computer and use it in GitHub Desktop.
Rails hack for using databases running in a virtual machine
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
# Rails only allows databases local to your machine. If you run your databases in a VM | |
# (and you should), then you need to add this | |
namespace :db do | |
def local_database?(config, &block) | |
if config['host'].in?(['127.0.0.1', 'localhost', '172.16.12.102']) || config['host'].blank? | |
yield | |
else | |
$stderr.puts "This task only modifies local databases. #{config['database']} is on a remote host." | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment