Skip to content

Instantly share code, notes, and snippets.

@statonjr
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save statonjr/9234483 to your computer and use it in GitHub Desktop.
Save statonjr/9234483 to your computer and use it in GitHub Desktop.
Rails hack for using databases running in a virtual machine
# 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