Count the Split up Tag values

Marra
2008-07-01T14:53:33Z

Hello!

I have in my database the tags for a specific entry separated by
commas and I''m using a SQL statement that pulls all the tags for a
bunch of entries and the ruby code on the page:

	<%- for notes in @tags_sql do -%>
	<% notes.tag.split(", ").uniq.each do |tags| %>
<%= link_to(tags, {:tag => tags, :controller =>
''project'', :action => ''tags'', :id =>
@project_id}) %>
	<% end %>

It''s able to split after each ", " so I have each tags listed
in the
unordered list but I also need to have next each individual tag the
count of how many times that tag shows up across the sql statement.

Is there anyway to do that in my code? I know I can''t do it in my SQL
statement because it counts the entire chunk per entry like "a, b, c,
d" instead of a b c d - it gets broken up in that code I put above.

Basically if its "a, c, a, d" I got it so far to be

a
c
d

BUT! I need it to be

a (2)
c (0)
d (0)

Any help would be appreciated. You guys are really awesome.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org