Hello RoR Developers,
I have tiny problem with sorting hash. I can not sort hash values.
i have hash which is created by yaml file. yaml file
template1: template_of_roster3: template_of_roster2 template_of_roster4: template_of_roster3
controller:
@get_config=YAML.load(File.open("#{PATH_IM}/.......yml")) @get_config == Hash @enterprises==Hash @my_hash=@get_config["template1"]
and I use this hash in my selection like
view:
<% templateOptions = "" @sites.each do |key,value| templateOptions = templateOptions + "<option value=#{key}>#{value}</option>" end %> <%=select_tag "templates", templateOptions,{'style' => 'width:100px' } %>
in fact there is no problem here but when I update my hash like this @new_hash={"new_hash"=>"new_hash"} @my_hash.update(@new_hash)
it s sorted like, new_hash template_of_roster2 template_of_roster3
but I want to see new_hash at the last option. how can I do it? any idea.
thanks