title: rails 3 combining form helpers with HTML/javascript form logic
body: <p>I need some advice on whether I am taking the right approach for my web form with a twist.</p>
  
  <p>I have this simple model that essentially consists of 2 fields. Here's the migration for it:</p>
  
  <pre><code>    class CreateAssetAllocations &lt; ActiveRecord::Migration
        def self.up
          create_table :asset_allocations do |t|
            t.string :asset_allocation
            t.date :effective_date
            t.timestamps
          end
        end
     end
  </code></pre>
  
  <p>The only twist with this model is that <code>asset_allocation</code> is not just a simple string. Instead, it is a list of comma-separated values (CSVs).</p>
  
  <p>However, I don't want to expose the CSV formatting to the web form used for creating new instances of the model. So my 'new' view template has the following general form:</p>
  
  <ul>
  <li>it uses <code>date_select</code> rails helper for entering the <code>effective_date</code> field</li>
  <li>It has an array of input objects for entering the individual components of the <code>asset_allocation</code> CSV. For these, I'm using native HTML <code>&lt;input&gt;</code> tags with callouts to jQuery validation logic to make sure that the individual elements are consistent with one another.</li>
  <li>I have native HTML <code>&lt;button&gt;</code> element that I've created for submitting the form. It is bound to some jQuery logic which loops through the <code>&lt;input&gt;</code> fields and packs it all into a CSV string prior to sending it to the server. Once the CSV string is ready, it calls <code>jQuery.post()</code> with the CSV data.</li>
  </ul>
  
  <p>Here is my button logic for submitting the form:</p>
  
  <pre><code>&lt;script&gt;
    function okGo() {
      var result=""
      $('.classentry option:selected').each(function() {
        var tag = $(this).val();
        var value = $(this).parent().next().val();
        result += tag + ":" + value + ",";
      });
      alert(result);
      $.post("&lt;%=security_assets_path(@security)%&gt;", { foo: result, asset_allocation: asset_allocation } );
    }
  &lt;/script&gt;
  &lt;button onClick="return okGo();"&gt;Go&lt;/button&gt;
  </code></pre>
  
  <p>Here is the call to <code>date_select</code> (see below). You can see that I'm assigning the object to the <code>asset_allocation</code> variable. If you look at the call to <code>$.post()</code> above, you'll see that I try to include the <code>asset_allocation</code> object in the posted data but it doesn't work. The <code>foo</code> data goes fine but not the <code>asset_allocation</code>.</p>
  
  <pre><code>Enter Effective Date:&lt;br /&gt;
  &lt;%= date_select("asset_allocation", "effective_date")%&gt;
  </code></pre>
  
  <p>The above solution works fine for sending the CSV data to the server. However,  I don't know how to get access to the <code>date_select</code> helper data to include in the call to <code>$.post()</code>.</p>
  
  <p>Is there a different approach that I should take for this situation?</p>
  
  <p>Thanks</p>