DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Request Database Authentication When Rails Boots

01.24.2007
| 6427 views |
  • submit to reddit
        Simple solution to a problem that may not affect very many folks.
If you don't like your password displayed in plain text in database.yml, this might help you.
It utilizes the Highline gem (big thanks to James Edward Gray II).

# database.yml

<%
require 'highline/import'

def request_input(msg, show_input = true)
  ask(msg) { |q| q.echo = show_input }
end
%>

#...
  username: <%= request_input 'Username: ' %>
  password: <%= request_input 'Password: ', false %>
#...
    

Comments

Wiktor Macura replied on Fri, 2006/06/09 - 2:22pm

Hey! That's great, thanks a lot for this. I've always been a bit figgity about keeping the password in plain text. Many thanks. Wiktor