I have a table that is displaying a list of 5 items. Next to each item I
want to display the number of times that the item pops up in an
individual list. Example:

Item1 (4)
Item2 (2)
Item3 (1)
Item4 (7)
Item5 (3)

Here is my code as is:

Index.rhtml.erb

<%= table.item1 + '</br>' + @statcount %>
<%= table.item2 + '</br>' + @statcount %>
<%= table.item3 + '</br>' + @statcount %>
<%= table.item4 + '</br>' + @statcount %>
<%= table.item5 + '</br>' + @statcount %>

-------------------------------

And the code used for counting each item in the controller (here is
where I'm having trouble)

item_ids = 1..5
    statcount_query = item_ids.map{|id| "item#{id} = BLANK "}.join(" OR
")
    @statcount = table.count(:all, :conditions => statcount_query).to_s

----------------------------------------------------------------------------

Where I have written BLANK is where I can't find the right code to
insert. I need to define/pass <%= table.item1 %> into this section, but
I'm quite lost on how to do it exactly. I've tried several methods, but
they keep returning nothing or the total amount of items in the table.


Any help would be greatly appreciated!
-- 
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