title: How to avoid a 'frozen hash' error in Rails without using an empty begin-rescue-end loop?
body: <p>I have the following method which is called via Ajax:</p>
  
  <pre><code>def decrement
      @cart = current_cart
      @line_item = LineItem.find(params[:id])
      @line_item.quantity -= 1
      if @line_item.quantity == 0
        @line_item.destroy
      end 
  
      begin @line_item.update_attributes(params[:line_item])
      rescue
      end
      respond_to do |format|
        format.js {@current_item = @line_item}
      end
  end
  </code></pre>
  
  <p>Originally, I had @line_item.update_attributes(params[:line_item]) in an if statement but that would return a "frozen hash" runtime error instead of merely returning false. I think that my begin-rescue-end loop is absolutely ridiculous, though it works, and I am here to ask the proper way to handle this situation in Rails.</p>