Q:

Get value from ruby key, from other ruby key value

Lets say I have the following in an array:
[
  {:region=>"beta", :db=>"CLIENTDB1"},
  {:region=>"prod", :db=>"CLIENTDB2"},
  {:region=>"train", :db=>"CLIENTDB3"}
]

I want to be able to call the variable and get the value beta, by saying that db = CLIENTDB1.  Kinda like a sql statement that would do, "select region where db = CLIENTDB1"
Also, I am on ruby 1.8.7, so .key won't work for me. 

A:

Try:
@var.find {|h| h[:db] == 'CLIENTDB1'}[:region]

