Skip to content

Instantly share code, notes, and snippets.

@henrik
Created June 21, 2010 18:39
Show Gist options
  • Save henrik/447287 to your computer and use it in GitHub Desktop.
Save henrik/447287 to your computer and use it in GitHub Desktop.
Per-branch development database with Git and Ruby on Rails.
<%
DEFAULT_DB = 'myapp_development'
DB_BRANCHES = %w[ t79 ]
branch = `git symbolic-ref HEAD 2> /dev/null`.chomp.split('/').last
dev_db = DB_BRANCHES.include?(branch) ? branch.gsub(/[^a-zA-Z0-9_]/, '') : DEFAULT_DB
puts "Using dev database: #{dev_db.inspect}"
%>
development:
database: <%= dev_db %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment