The dbi-dbrc library provides an interface for storing database connection information, including passwords, in a locally secure file only accessible by you, or root. This allows you to avoid hard coding login and password information in your programs that require such information. This library can also be used to store login and password information for logins on remote hosts, not just databases.
Gemfile gem 'dbi-dbrc', '~> 1.1.7'
install gem install dbi-dbrc -v 1.1.7