in Ruby module "D3" i have defined :
=================================def dumpAttributes(strPrefix = "")
@attributes.each_pair do | key, value |
puts "#{strPrefix}#{key} : #{value}"
end
end
================================and in my Controller when i use :
@mdb.dumpAttributes("==> ")
i can see in radrail console that i get all values with key printed
using puts, but instead of puts i want to store in some array so tht i
can use same arry in my view
Can anyone suggest me how i can use "key,value" from method into my
controller.
Iam not good in ROR , so iam sorry if it''s a silly question.
Help me.
Rama
--
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
-~----------~----~----~----~------~----~------~--~---
Rama Singh wrote:> in Ruby module "D3" i have defined : > =================================> def dumpAttributes(strPrefix = "") > @attributes.each_pair do | key, value | > puts "#{strPrefix}#{key} : #{value}" > end > end > ================================> and in my Controller when i use : > @mdb.dumpAttributes("==> ") > > i can see in radrail console that i get all values with key printed > using puts, but instead of puts i want to store in some array so tht i > can use same arry in my view > > Can anyone suggest me how i can use "key,value" from method into my > controller. > > Iam not good in ROR , so iam sorry if it''s a silly question. > > Help me. > > RamaAssuming that @attributes is a Hash: def dumpAttributes(strPrefix = "") @attributes.collect do |key,value| "#{strPrefix}#{key} : #{value}" end end Collect is like each_pair but returns an Array the block (do .. end) evaluation results. Have fun Skade -- 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 -~----------~----~----~----~------~----~------~--~---
Florian Gilcher wrote:> Rama Singh wrote: >> in Ruby module "D3" i have defined : >> =================================>> def dumpAttributes(strPrefix = "") >> @attributes.each_pair do | key, value | >> puts "#{strPrefix}#{key} : #{value}" >> end >> end >> ================================>> and in my Controller when i use : >> @mdb.dumpAttributes("==> ") >> >> i can see in radrail console that i get all values with key printed >> using puts, but instead of puts i want to store in some array so tht i >> can use same arry in my view >> >> Can anyone suggest me how i can use "key,value" from method into my >> controller. >> >> Iam not good in ROR , so iam sorry if it''s a silly question. >> >> Help me. >> >> Rama > > Assuming that @attributes is a Hash: > > > def dumpAttributes(strPrefix = "") > @attributes.collect do |key,value| > "#{strPrefix}#{key} : #{value}" > end > end > > Collect is like each_pair but returns an Array the block (do .. end) > evaluation results. > > Have fun > SkadeThanks Skade for your help, but still i need help in more depth, dumpAttributes() is in another file "x.rb"..i have included this file. I want to bring values in an array form to use in my controller. So my question is how i can store "key,value" in array, and how to get tht array in my controller Rama -- 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 -~----------~----~----~----~------~----~------~--~---