From: Rob Kaufman Date: 2010-03-11T09:55:11+09:00 Subject: Re: iterate through an @Array Hey John, You just need to move the table start and end outside of the each statement. Everything inside the each block gets done for each item in the array: # Do once puts "" @sample_array.each do |t| # Do for every item in the array (make one row per item) puts"" end # Do once puts “
#{t.name}#{t.address}#{t.city}#{t.state}
” On Wed, Mar 10, 2010 at 16:35, John William wrote: > New to ruby > If I have an Array > > @sample_array > > How do I display the attr_accessors in a table > This doesn’t seem to be the right way as it repeats the table each time > it iterates through the array. > > Thanks, > > John > > @sample_array.each do |t| > puts "" > puts" tr>" > puts “
#{t.name}#{t.address}#{t.city}#{t.state}
” > end > -- > Posted via http://www.ruby-forum.com/. > > -- Rob Kaufman http://notch8.com gtalk/jabber/email: rob@notch8.com p: 858-412-7749 f: 866-477-1620