Frederick Cheung wrote in post #1033844:
> On Nov 26, 4:03pm, "Mohnish J." <li...@ruby-forum.com> wrote:
>> Frederick Cheung wrote in post #1033717:
>
>> Hi Fred,
>>
>> Kindly correct me if I am wrong.. Are you saying I can use the inspect
>> method to get the value of the aliased "total" attribute ?
>>
> No
>> I don't think you meant that, but just confirming..
>>
>> If not, how else would I be able to get the value of total as a count of
>> all users residing in each area of a city?
>>
> users = User.select('area, count(area) as
> total').group('area').order('total
> DESC').limit(30)
> users[0].total
>
> Fred

Hi Fred..

Thanks,

This worked like magic..:). I would like to deep dive into how exactly 
active record is dealing with storing such queries...processing them... 
Rails Guides was my one stop ref but , I couldn't find trace for more 
examples dealing with such requirements...Where can I find more info on 
this ...?

I tried a users.inspect, it gave me no trace of a 'total' attribute.. 
which data structure is being generated and used to store the result of 
this Rails query..?? Based on your answer..

Thanks again for your help...

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to