Retrieving Global Arrays


#1

I inherited an app that created STATES & COUNTRIES as global hashes in
config/environment.rb

STATES = {}
STATES[:AL] = ‘Alabama’
STATES[:AK] = ‘Alaska’
STATES[:AZ] = ‘Arizona’

I’m able to render the name correctly like this…
<%= STATES[:AK] %>

But what is the syntax to call that dynamically? This does not
work…
<%= STATES[location.state] %>

Thanks, I’m stumped on this noob issue.


#2

<%= STATES[location.state.to_sym] %> ?

Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)