RailsCasts Pro episodes are now free!
Learn more or hide this
There is a newer version of this episode, see the revised episode.
Resources
APP_CONFIG = YAML.load_file("#{RAILS_ROOT}/config/config.yml")[RAILS_ENV]
def authenticate if APP_CONFIG['perform_authentication'] authenticate_or_request_with_http_basic do |username, password| username == APP_CONFIG['username'] && password == APP_CONFIG['password'] end end end
development: perform_authentication: false test: perform_authentication: false production: perform_authentication: true username: admin password: secret