heroku_external_db

Allows you to easily set up one or more external databases in Rails applications from Heroku, including the ability to do MySQL connections over SSL. This is useful in the following situations, for example:

  • Your app connects to multiple databases using differently-named ActiveRecord connections.

  • You want to share a database between applications and aren’t on the Heroku dedicated database plan.

  • You want to host your application database somewhere besides Heroku, and run the app using Heroku dynos.

Usage

Add the following to your Gemfile:

gem 'heroku_external_db'

Then run:

bundle install
rails generate heroku_external_db:generator

This will set up a default initializer in your app’s config/initializers/heroku_external_db.rb. This makes the assumption that you’re happy with using EXTERNAL_DATABASE_URL and (optionally) EXTERNAL_DATABASE_CA as your environment variables and that you want to use the external database as your main production DB. If that’s not true, please edit the initializer as needed.

Contributing to heroku_external_db

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2011 Nat Budin. See LICENSE.txt for further details.