I have a non-Rails project in which I am loading some settings from a YAML file:
config = YAML::load File.open("#{LOG_ROOT}/config/database.yml")
I can only access this hash like config["host"]
, config["username"]
etc.
I want indifferent access so I can use both :host
and "host"
.
The reason is, that one of the gems in the project to which I am passing this hash seems to be accessing it using symbols and it fails currently.
What is the best way to create a hash with indifferent access in this scenario?
require 'active_support/core_ext/hash/indifferent_access'
, and there's your solution? - Casper