title: jQuery UI Autocomplete in Rails, updating hidden field with ID attribute
body: <p>I have this in my form, it's really simple:</p>
  
  <pre><code>&lt;script&gt;
      $(function() {
          var availableProducts = [
               &lt;% @products.each do |p| %&gt;"&lt;%= p.id %&gt; &lt;%= p.title %&gt; (&lt;%= p.product_type.name %&gt;)",&lt;% end %&gt;
               ""
          ];
          $( "#tags" ).autocomplete({
              source: availableProducts
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>That gives me lists of things like 1 Title (Trade Paperback). All rails needs of course, is the id attribute. I'd planned on updating a hidden field with the attribute, using the <code>select:</code> event, but <strong>I'm not quite sure how to extract just the id from the data source to update the hidden field with.</strong> Should I change the data source to something that can have keys? Like JSON? I still wouldn't know how to extract from that.</p>
  
  <p>Here's what the above code looks like in straight html:</p>
  
  <pre><code>&lt;script&gt;
      $(function() {
          var availableProducts = [
                "1 Test Title (eBook)",
                "2 Another Test Title (eBook)",
                ""
          ];
          $( "#products" ).autocomplete({
              source: availableProducts
          });
      });
  &lt;/script&gt;
  </code></pre>