title: Update database attribute from Javascript
body: <p>In my ruby on rails app, I am trying to allow a user to change a field on the screen and as a result, update the database. </p>
  
  <p>A user is promoted with the following screen: </p>
  
  <pre><code>&lt;td id="sb_user-&lt;%=server.id%&gt;" ondblclick="changeUser(&lt;%= server.id %&gt;);"&gt;&lt;%= server.sb_user %&gt;&lt;/td&gt;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/5cSJw.png" alt="enter image description here"></p>
  
  <p>When they double click on the sb_user field, a javascript function is called and changes the field to a textbox with a simple go button:</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
          function changeUser(id) {
              //Stop the auto refresh until user hits enter
              clearInterval(refreshInterval);
              $("#sb_user-"+id).html("&lt;form name='user'&gt;&lt;div class='input-append'&gt;&lt;input name='user_input' class='span1' id='appendedInputButton' size='16' type='text'/&gt;&lt;button class='btn' type='button'&gt;Go!&lt;/button&gt;&lt;/form&gt;&lt;/div&gt;"); 
          }
      &lt;/script&gt;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/QBdTa.png" alt="enter image description here"></p>
  
  <p>When a user enters text into the textbox and clicks go, I need it so that the database field server.sb_user is updated to whatever the user entered in that field.</p>
  
  <p>Anyone have suggestions on how to do this? </p>