Forum: Ruby on Rails Retrieving Global Arrays

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Sav (Guest)
on 2009-01-21 21:07
(Received via mailing list)
I inherited an app that created STATES & COUNTRIES as global hashes in

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
<%= STATES[location.state] %>

Thanks, I'm stumped on this noob issue.
Maurício L. (Guest)
on 2009-01-21 21:10
(Received via mailing list)
<%= STATES[location.state.to_sym] %> ?

Maurício Linhares (pt-br) |
This topic is locked and can not be replied to.