title: ruby rails edit attribute using a button
body: <p>Suppose I have an object @transaction that gets shown /transactions/id</p>
  
  <pre><code>def show
      @transaction = Transaction.find(params[:id]);
  end
  </code></pre>
  
  <p>In show.html.erb, I want to have a button that when pressed changes one of the attributes of Transaction. How do I do that?</p>
  
  <p>In show.html.erb, I have</p>
  
  <pre><code>&lt;%= form_for @transaction do |t| %&gt;
      &lt;%= t.label :id %&gt; : &lt;%= @transaction.id %&gt;&lt;br /&gt;
  
      &lt;%= t.submit "pay" %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>EDIT: I think I may have misled with the question. The button code above generates this html:</p>
  
  <pre><code>&lt;input id="transaction_submit" name="commit" type="submit" value="pay" /&gt;
  </code></pre>
  
  <p>When I click on the button, the "update" method in the controller is called. How do I pass the value from a button to a specific action in the update method? For example, suppose <code>button1</code>changes the transaction.name to "lalala". How do I do this?</p>
  
  <pre><code>def update
    // if button1 is pressed, change transaction.name to lalala
    // if button2 is pressed, change transaction.amount to bobobo
  end
  </code></pre>