Jay Covington wrote:
> Marnen Laibow-Koser wrote:
>> Jay Covington wrote:
>> [...]
>>> item_ids = 1..5
>>>     statcount_query = item_ids.map{|id| "item#{id} = BLANK "}.join(" OR
>>> ")
>>>     @statcount = table.count(:all, :conditions => statcount_query).to_s
>> 
>> Well, first of all, you can forget about the map statement and put the 
>> array item_ids straight into :conditions -- Rails will understand it. 
>> But that won't get you what you need, because it will just return a 
>> total count of all the items that match *any* ID.  I think you need to 
>> use :group here.
>> 
>> Best,
>> --
>> Marnen Laibow-Koser
>> http://www.marnen.org
>> [email protected]
> 
> I've tried the group method listed below for an individual column, but 
> it returns just the column entry for "item1" and not the number of 
> occurances or count. All I'm getting for the count is "#". Perhaps this 
> code is outdated? Is the there a problem in my controller?
> 
> table.find(:all, :select => "item1, count(item1) as occurance",
>>                       :group => "item1")
>> 

Still no luck. Is there a way to reference <%= table.item1 %> where 
BLANK is in the following code?:

item_ids = 1..5
    statcount_query = item_ids.map{|id| "item#{id} = BLANK "}.join(" OR 
")
    @statcount = table.count(:all, :conditions => statcount_query).to_s
-- 
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 [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
-~----------~----~----~----~------~----~------~--~---

Reply via email to