Forum: Ruby on Rails Using "eval" to display a summary

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Rake N. (Guest)
on 2009-01-09 09:03
Hi,

Anyone can helps to display a summary list instead of a details list.

Here is my code;

recgroup = eval(tablename.fieldname) if !tablename.fieldname.nil?

puts  recgroup[:textgroup] + recgroup[:countgroup].inject(0) {|sum,
room| sum + room.length}.to_s + '; ' + recgroup[:countgroup].length.to_s
if !recgroup.nil?


It was displays as a details;

textdata1 1 1
textdata2 1 2
textdata1 2 2


But I need to display as a summary;


textdata1 3 3
textdata2 1 2


Thanks!
This topic is locked and can not be replied to.