When you are running a small / medium sized project, there is usually not a dedicated DBA and you rarely care about the database analytics that PostgreSQL gives you for free. Elefant tries to help a little by providing a web interface for some basic database analytics as a small mountable rack application.
Add this line to your application's Gemfile:
gem 'elefant'
And then execute:
$ bundle
Or install it yourself as:
$ gem install elefant
Run the web interface as a standalone rack application:
$ DATABASE_URL=postgres:///some_db_connection_string elefant-web
or if you want to use a different database specifically for elefant:
$ ELEFANT_DATABASE_URL=postgres:///some_db_connection_string elefant-web
You can mount the web interface in a rails application by adding this to config/routes.rb
:
require 'elefant/web'
mount Elefant::Web => '/elefant'
It will pick up a connection from the ActiveRecord
connection pool.
In case you are using Devise, here is an example of mounting only for
authenticated users of the :admin
scope:
authenticate(:admin) do
require 'elefant/web'
mount Elefant::Web => '/elefant'
end
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request