title: Increment integer on save in Rails 3?
body: <p>I have the following code in my Rails 3 application:</p>
  
  <pre><code> def like
      @suggestion = Suggestion.find(params[:id])
      Suggestion.update_all("votes = (votes + 1)")
      redirect_to suggestions_url
    end
  
    def dislike
      @suggestion = Suggestion.find(params[:id])
      Suggestion.update_all("votes = (votes - 1)")
      redirect_to suggestions_url
    end
  </code></pre>
  
  <p>It's working, but rather than updating the current suggestion it's updating them all. So I changed it to:</p>
  
  <pre><code> def like
      @suggestion = Suggestion.find(params[:id])
      @suggestion.update_all("votes = (votes + 1)")
      redirect_to suggestions_url
    end
  
    def dislike
      @suggestion = Suggestion.find(params[:id])
      @suggestion.update_all("votes = (votes - 1)")
      redirect_to suggestions_url
    end
  </code></pre>
  
  <p>but then I get:</p>
  
  <pre><code>undefined method `update_all' for #&lt;Suggestion:0x007f87c2b918a0&gt;
  </code></pre>
  
  <p>So then I tried <code>@suggestion.update_attribute(:votes, '1')</code> but that resets the value to 1 instead of incrementing it.</p>
  
  <p>What's the correct way to achieve this? I just want the integer (votes) of the current suggestion to increment/decrease by 1 on each save.</p>
  
  <p>I've also tried the following with no luck:</p>
  
  <pre><code>def like
   @suggestion = Suggestion.find(params[:id])
   @suggestion.increment(:votes)
   redirect_to suggestions_url
  end
  </code></pre>