On 17 March 2010 13:33, Clay H. wrote:
> the only issue is that amount_on_hand is a method
> in the Medicine model, not in the Stock model -- it performs an
> aggregate sum for all of the stocks belonging to the medicine in
> question. This code uses it as a Stock method, doesn't it?
Of course -
On Mar 16, 12:45 pm, Michael Pavling wrote:
> On 16 March 2010 15:57, Michael Pavling wrote:
>
> >> Also, is it possible to order the hash so that they appear in
> >> descending order of how much of each item is in stock? In other words,
> >> sort descending by the value that the following genera
On 16 March 2010 15:57, Michael Pavling wrote:
>> Also, is it possible to order the hash so that they appear in
>> descending order of how much of each item is in stock? In other words,
>> sort descending by the value that the following generates?
>>
>> <%=h "#{s.last.sum(&:amount_received) -
>> s
On 16 March 2010 15:33, Clay H. wrote:
> On Mar 16, 8:33 am, Michael Pavling wrote:
>>
>> And post again if you need any more help.
>
> Hey, thanks for the help so far. I went with a method in the
> Medicine.rb model file and I'm trying to display the results through
> the view, using code simila
On Mar 16, 8:33 am, Michael Pavling wrote:
>
> And post again if you need any more help.
Hey, thanks for the help so far. I went with a method in the
Medicine.rb model file and I'm trying to display the results through
the view, using code similar to what you suggested. I modified the
code to app
On 16 March 2010 12:03, Clay H. wrote:
> On Mar 15, 9:25 pm, Michael Pavling 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_dispen
On Mar 15, 9:25 pm, Michael Pavling 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 wo
7 matches
Mail list logo