Hello RoR Developers,
I got question about selection again. I got template.yml file
id1051256120:
  template_of_roste1: Name1
  template_of_roster2: Name2
I get my selections options from this yml file like,
controller
@site_id="id"+current_hierarchy.site_id.to_s
@get_config=YAML.load(File.open("#{PATH_IM}/config/template.yml"))
@get_config  == Hash
@sites=@get_config[@site_id].values
@merge= @sites
view
<%= select_tag "templates",
options_for_select(@merge) %>
my question here is how can I create selection like
<select id="templates">
    <option
value="work_sheet_csv">work_sheet_csv1</option>
    <option value=" template_of_roste1">Name1</option>
    <option value=" template_of_roster2">Name2</option>
  </select>
I want to get the values from first column and the names from second
column.
thanks
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
least could somebody tell me where is my mistake.
controller
@site_id="id"+current_hierarchy.site_id.to_s
@get_config=YAML.load(File.open("#{PATH_IM}/config/template.yml"))
@get_config  == Hash
@merge==Hash
@merge==@get_config[@site_id]
view
<%
            templateOptions = ""
            @merge.each do |key,value|
                templateOptions = templateOptions + "<option 
value=#{key}>#{value}</option>"
            end
            %>
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
ok
this one will be more clear.
I have a template.yml file, like this
template:
  templatename1: template_of_roster
  templatename2: template_of_roster1
  templatename3: template_of_roster2
template1:
  templatename1: template_of_roster32
  templatename2: template_of_roster143
  templatename3: template_of_roster2423
I want to use yaml keys and values in my selection. like,
@get_config=YAML.load(File.open("#{PATH_IM}/config/template.yml"))
@get_config  == Hash
<select id="templates">
    <option 
value="<%=@get_config[template].keys%>"><%=@get_config[template].values%></option>
  </select>
this one is not my problem actually, I can do it, my problem is
I have two hashes one is
@hash1==Hash
@hash1=@get_config[template]
other one is
@hash2==Hash
@hash2=@get_config[template1]
I want to merge these two hashes in one and create selection like above.
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---