Frederick Cheung wrote:
> On Jun 6, 3:59�pm, Jay Covington <[email protected]>
> wrote:
>>
>> 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
> 
> What does your data look like ? count will always return either a
> single number or a hash of values to counts (if you've used a :group
> option) (to be quite precise, an instance of
> ActiveSupport::OrderedHash which depending on the rails version you
> have is backed by a different class).
> 
> Fred

The data is simply a database of lists. For example, the list 
("grocery") that  contains: "title", "item1", "item2", "item3", "item4, 
"item5". It was built behind a scaffold. So the index.rhtml shows all of 
my lists. Ok, no problem there. Here is example output:

"Grocery List"
Apples
Pears
Oranges
Blah..
Blah..

and the list output is coded in the index of course as :
<%= title.grocery %>
<%= item1.grocery %>
<%= item2.grocery %>
etc.
etc.

----------------------------------------------------------------------------
The format that I need to achieve is the same list of items but with 
counts next to them. So below, I can see that Apples appear in 4 
different lists (including this one) while Oranges appear in 5 lists.

"Grocery List"
Apples 4
Pears 1
Oranges 5
Blah..  8
Blah..  10

---------------------------------------------------------------------------
Hopefully that gives an idea of what I'm trying to do. The closest that 
I've come to code wise is the below, but I don't know how to connect the 
table output to it or if there is totally another method for 
accomplishing the same thing.


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