On 15 March 2010 22:07, Clay H. <[email protected]> wrote:
> I've been reading on the group_by() method for enumeration
>
> Any help with this method or suggestions for alternative approaches
> would be appreciated! I'd like to get the system updated as soon as I
> can. Thanks!
Using Enumerable.group_by:
Stock.all.group_by{|s| [s.medicine.name, s.route.name, s.strength]}.each do |s|
puts "#{s.first.inspect} #{s.last.sum(&:amount_received) -
s.last.sum(&:amount_dispensed)}"
end
Does that give you enough to work with?
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.