title: How do I create a button that increments an attribute of a model and can be pressed once per browser?
body: <p>An <code>apartment_listing</code> has many <code>reviews</code>, and a <code>review</code> belongs to an <code>apartment_listing</code>. </p>
  
  <p>In the file <code>views/apartment_listings/show.html.erb</code>, I show a list of reviews for that particular <code>apartment_listing</code>. These reviews are generated with the partial view <code>apartment_listings/_review.html.erb</code> like so:</p>
  
  <pre><code>&lt;%= render :partial =&gt; "review", :collection =&gt; @apartment_listing.reviews %&gt;
  </code></pre>
  
  <p>In <code>_review</code>, I want to have a button that, when pressed:</p>
  
  <ol>
  <li>Increments that review's <code>helpful_count</code> attribute.</li>
  <li>Makes it so that it cannot be pressed again while in the same browser - probably using cookies.</li>
  </ol>
  
  <p>I feel like the former shouldn't be too hard to figure out, but it's got me beat. I'm really not sure where to start with the second goal.</p>
  
  <hr>
  
  <p>EDIT: I managed to update the review's <code>helpful_count</code> attribute with this code in <code>apartment_listings/_review.html.erb</code>:</p>
  
  <pre><code>&lt;%= form_for review, :method =&gt; :put, :remote =&gt; true do |f| %&gt;
    &lt;%= f.hidden_field :helpful_count, value: (review.helpful_count + 1) %    &gt; 
    &lt;%= f.submit 'Helpful?' %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>However, I'm not sure if this is the best way to do it, and I'd like to be able to disable the button after it is clicked.</p>