How to get array values in Ruby On Rails -
i working on localization concept in rails , need of localization values in html pages. generated array in controller below format.,
#array use store localization values @alertmessages = [] #array values... {:index=>"wakeup", :value=>"wake up"} {:index=>"tokenexpired", :value=>"token expired"} {:index=>"timezone", :value=>"time zone"} {:index=>"updating", :value=>"updating"} {:index=>"loadmore", :value=>"load more"} #....more
in html pages want localization values below or other type,
<%= @alertmessages['wakeup'] %>
so, display value 'wake up',
but not working.. can 1 please...
it's easier use hash (http://api.rubyonrails.org/classes/hash.html), array named indexes (or keys).
so this:
@alertmessages = { :wakeup => "wake up", :tokenexpired => "token expired", . . . }
you can extend hash way:
@alertmessages[:loadmore] = "load more"
access using:
@alertmessages[:loadmore]
also should check i18n internationalization, more robust , flexible way: http://guides.rubyonrails.org/i18n.html