title: Problem Counting Number of Times a Link is Clicked in Rails
body: <p>I have a database with a number of records in it, each with an associated URL.  Currently I have things set up so that when people click on a link for a particular record they get redirected to the appropriate URL.  The code is currently:</p>
  
  <pre><code>&lt;%= link_to image_tag( alldata.picture.to_s + ".gif"), alldata.URL_link %&gt;
  </code></pre>
  
  <p>This does its job fine.  I would like to now modify this so when the link is clicked on, a parameter called <code>:click_count</code> which is orignally set to 0 for all records.</p>
  
  <p>Reading around, I believe you can do this using something of the following form:</p>
  
  <pre><code>&lt;%= link_to image_tag( alldata.picture.to_s + ".gif"), alldata.URL_link, {:controller =&gt; params[:controller], :action =&gt; "clickcountplusone", :product_name =&gt; alldata.product_name}  %&gt;
  </code></pre>
  
  <p>With the following in the controller:</p>
  
  <pre><code>def clickcountplusone
    clickeditem = Entiredatabase.find(params[:product_name])
    clickeditem.update_attribute(:click_count =&gt; clickeditem.click_count + 1)
  end
  </code></pre>
  
  <p>Although this does not produce an error, it also doesn't increase the count number... Could anyone shed any light on the issue?</p>