Trying to create a counter for a link being clicked


im trying to create a counter for each time a link is clicked, but new
links can be created, so somehow i need it a count value to be linked to
each link, so that only that the clicked countre increments by 1.

suppose i have


i would like if link1 had been clicked 4 times, it to refer to link1,4
if a new link was created, then it begins at 0

similarly if a link is created the counter is removed from the hash.

i presume this may require a hash. ive been hacking down that road, but
not getting very far.

my controller:

def new

    @testrun.start_date =
    @testrun.count = $counter

     $counter += 1

this increments a counter, but will simply increment one count for all

any help would be really appreciated!

thanks in advance.