title: How to update model with ajax in rails
body: <p>I am developing my first Ruby on Rails real application, and I want to achieve a very simple task:</p>
  
  <p>I have an input in my view, whose value represents a field of one of my models. I want to, via ajax, update this field in my model when the user changes the value of the input.</p>
  
  <p>How can I do that?</p>
  
  <p>Thanks a lot</p>
  
  <p>html code:</p>
  
  <pre><code>Product#View
  ...
  Stock: &lt;input type="text" name="p[stock]" placeholder="Stock" value="&lt;%= @product.stock %&gt;" /&gt;&lt;br&gt;
  ...
  </code></pre>
  
  <p>controller:</p>
  
  <pre><code>def view
    @product = Product.find(params[:id])
  end
  </code></pre>