On Mar 15, 9:25 pm, Michael Pavling <[email protected]> wrote: > 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?
I think so. I can create a method in the Medicine model that includes this code and then call that method on each med on the the show and/or index views, right? If I go with the SQL you suggested above, where would I use that? Also in a method in the Model? -- 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.

