Hi RoR Developers I got tiny problem here. Actually I asked before but there was not any answer and asking again. I have template.yml file.] get_config=YAML.load(File.open("..../template.yml")) $temp1path=get_config["template"]["templatename1"] I can get the values by using matrix one by one like above but how can I list only right side I mean this is my template.yml file template: templatename1: template_of_roster.xml templatename2: template_of_roster1.xml templatename3: template_of_roster2.xml templatename4: template_of_roster3.xml only this column. template_of_roster.xml template_of_roster1.xml template_of_roster2.xml template_of_roster3.xml thank you for any help or commend. -- 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 -~----------~----~----~----~------~----~------~--~---
On Feb 28, 2008, at 12:54 AM, Ibrahim Dogru wrote:> Hi RoR Developers > > I got tiny problem here. Actually I asked before but there was not any > answer and asking again. > > I have template.yml file.] > get_config=YAML.load(File.open("..../template.yml")) > $temp1path=get_config["template"]["templatename1"] > > I can get the values by using matrix one by one like above but how > can I > list only right side I mean this is my template.yml file > > template: > templatename1: template_of_roster.xml > templatename2: template_of_roster1.xml > templatename3: template_of_roster2.xml > templatename4: template_of_roster3.xml > > > only this column. > template_of_roster.xml > template_of_roster1.xml > template_of_roster2.xml > template_of_roster3.xml > > thank you for any help or commend.You''ll probably find that get_config.class == Hash so you can get the values with: get_config["template"].values which gives you an Array over which you could iterate with .each -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Rob Biedenharn wrote: On Feb 28, 2008, at 12:54 AM, Ibrahim Dogru wrote: can I template_of_roster.xml template_of_roster1.xml template_of_roster2.xml template_of_roster3.xml thank you for any help or commend. You''ll probably find that get_config.class == Hash so you can get the values with: get_config["template"].values which gives you an Array over which you could iterate with .each -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org I wrote something like this require ''yaml'' get_config=YAML.load(File.open("C:/yotta/config/template.yml")) get_config.class == Hash get_config["template"].values get_config.each do |k,v| puts v.inspect end result {"templatename1"=>"template_of_roster.xml", "templatename2"=>"template_of_roster1.xml", "templatename3"=>"template_of_roster2.xml", "templatename4""template_of_roster3.xml"} why I can not get only second column. I only want this side. template_of_roster.xml template_of_roster1.xml template_of_roster2.xml template_of_roster3.xml how should I change my codes. thank you very much for your help Rob Biedenharn .. -- 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 -~----------~----~----~----~------~----~------~--~---
On Feb 28, 2008, at 2:33 AM, Ibrahim Dogru wrote:> > Rob Biedenharn wrote: > On Feb 28, 2008, at 12:54 AM, Ibrahim Dogru wrote: > can I > template_of_roster.xml > template_of_roster1.xml > template_of_roster2.xml > template_of_roster3.xml > > thank you for any help or commend. > > > You''ll probably find that get_config.class == Hash > so you can get the values with: > get_config["template"].values > which gives you an Array over which you could iterate with .each > > -Rob > > Rob Biedenharn http://agileconsultingllc.com > Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org > > I wrote something like this > require ''yaml'' > get_config=YAML.load(File.open("C:/yotta/config/template.yml"))This is a boolean expression, it doesn''t *do* anything to the get_config object> get_config.class == HashYou should save this in a variable> get_config["template"].values > get_config.each do |k,v| > puts v.inspect > endor just do: puts get_config["template"].values> > result > {"templatename1"=>"template_of_roster.xml", > "templatename2"=>"template_of_roster1.xml", > "templatename3"=>"template_of_roster2.xml", "templatename4"> "template_of_roster3.xml"} > > why I can not get only second column. I only want this side. > template_of_roster.xml > template_of_roster1.xml > template_of_roster2.xml > template_of_roster3.xml > > how should I change my codes. > thank you very much for your help Rob Biedenharn ..You''re really not having issues with Rails, but with plain old Ruby (and YAML from the standard library, of course). -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
hmm how can I convert to string I mean I know to_s but how will I use it here. I want to assign the values to variable. I have selection which is taken these values. <% templateOptions = "" @templates.each do |i| templateOptions = templateOptions + "<option value=#{i}>#{i}</option>" end %> <%=select_tag "templates", templateOptions %> thank you very much again.. -- 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 -~----------~----~----~----~------~----~------~--~---
On Feb 28, 2008, at 2:55 AM, Ibrahim Dogru wrote:> hmm > how can I convert to string I mean I know to_s but how will I use it > here. I want to assign the values to variable. > I have selection which is taken these values. > > <% > templateOptions = "" > @templates.each do |i| > templateOptions = templateOptions + "<option > value=#{i}>#{i}</option>" > end > %> > <%=select_tag "templates", templateOptions %> > > thank you very much again..http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M000944 <%= select_tag "templates", options_for_select(get_config["template"].values) %> Even if you were to build it yourself, you might find Enumerable#map (aka, Enumerable#collect) and Array#join useful: templateOptions = @templates.map {|t| %{<option value="#{t}">#{t}</ option>} }.join These particular strings aren''t likely to pose a problem, but you should also know about ERB::Util#html_escape (often seen in views as just h) http://api.rubyonrails.org/classes/ERB/Util.html#M000148 -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> -Rob > > Rob Biedenharn http://agileconsultingllc.com > Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.orgthank you very much. -- 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 -~----------~----~----~----~------~----~------~--~---