Hi guys, I''m trying to figure out how to chain together group and
select, two finder methods in ActiveRecord 3.x so I have this
model
class Cow < ActiveRecord::Base
set_table_name :cows
belongs_to :farmer
end
with breed:string and milk_quantity:integer columns and in client
code:
result = Cow.select("breed,sum(milk_quantity) as
s").group(''breed'').all
that runs this query
SELECT breed,sum(milk_quantity) as s FROM "cows" GROUP BY breed
And the rdb results are right :
first breed --->100
second breed --->200
and so on..
My question is:
How can access sum(milk_quantity) result from result array of Cow?
--
Posted via http://www.ruby-forum.com/.
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.