title: Rails datepicker only works with _tag
body: <p>I'm new to RoR, and after reading a lot of articles here and on the web, I got datepicker working on my RoR project, to filter search results.  However, now I need to use datepicker to set some values in my model, but the _tag prevents that, and the create action does not save the dates in the DB.</p>
  
  <p>I tried dropping the _tag, but then the JS does not seem to activate on my webpage and the Datepicker no longer pops up (although if I manually enter a date in to the field, the create works fine and the date is stored in the DB).</p>
  
  <p>I tried using a hidden_field, and various other things to get it working and interacting with my model, but I am stuck.</p>
  
  <p>So I have two flavors of the same question:
  1 - How can I get datepicker to work without _tag?  Based on what I have seen on Stackoverflow, that is a normal use.
  2 - How can I use datepicker with a _tag and interact with my model?</p>
  
  <p>Below are the relevant snippets of my code for the datepicker with _tag that works.  Any help would be greatly appreciated!</p>
  
  <p>GEMFILE</p>
  
  <pre><code>gem 'rails', '4.2.2'
  gem 'jquery-rails',           '4.0.4'
  gem 'jquery-ui-rails'
  gem 'tinymce-rails'
  # Bootstrap and stuff
  gem "twitter-bootstrap-rails"
  gem 'bootstrap-sass',          '3.2.0.0'
  gem 'bootstrap-datepicker-rails'
  
  # Datatables
  gem 'jquery-datatables-rails', '~&gt; 3.3.0'
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>&lt;div class="row"&gt;
      &lt;%= form_tag("/vacations/list", method: "get", action: 'dateFilter') do %&gt;
    &lt;div class="col-md-2 col-md-offset-0"&gt;
        &lt;%= label_tag :start_date %&gt;
        &lt;%= text_field_tag :start_date %&gt;
        &lt;%= submit_tag "Filter by Date", class: "btn btn-primary" %&gt;
    &lt;/div&gt;
    &lt;div class="col-md-2 col-md-offset-0"&gt;
        &lt;%= label_tag :end_date %&gt;
        &lt;%= text_field_tag :end_date %&gt;
    &lt;/div&gt;
      &lt;% end %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>VACATIONS.JS</p>
  
  <pre><code>$(document).ready(function() {
  $('#vacations').dataTable({
      "pageLength": 25
  });
  $("#start_date").datepicker({dateFormat: 'yy-mm-dd'});
  $("#end_date").datepicker({dateFormat: 'yy-mm-dd'});
  });
  </code></pre>
  
  <p>VACATIONS CONTROLLER</p>
  
  <pre><code>def list
    get_data_set
    @start_date = params['start_date'] || ""
    @end_date = params['end_date'] || ""
      if @start_date.empty? &amp;&amp; @end_date.empty?
        @vacations = Vacation.all
      else
        @vacations = dateFilter
      end
    end
  
  def dateFilter
    @start_date = params['start_date']
    @end_date = params['end_date']
    @vacations = Vacation.where(start_date: @start_date..@end_date)
    return @vacations
  end
  </code></pre>
  
  <p>The fact that datepicker works fine with the _tag makes me think I am either close or doing something dumb.  Any help would be great.</p>
  
  <p>UPDATE:</p>
  
  <p>Here is the HTML for the new use case that half works - if I fill in the start_date and end_date field manually, I can update the model, but clicking on the field does not kick of the JS to bring up the Datepicker.</p>
  
  <pre><code>&lt;div class="row"&gt;
    &lt;div class="col-md-6 col-md-offset-3"&gt;
      &lt;%= form_for(@vacation_report) do |f| %&gt;
  
        &lt;%= f.label :timeperiod_name %&gt;
        &lt;%= f.text_field :timeperiod_name, class: 'form-control' %&gt;
  
        &lt;div class="row"&gt;
          &lt;div class="col-md-2 col-md-offset-0"&gt;
            &lt;%= f.label :start_date %&gt;
            &lt;%= f.text_field :start_date %&gt;
          &lt;/div&gt;
        &lt;div class="col-md-2 col-md-offset-0"&gt;
            &lt;%= f.label :end_date %&gt;
            &lt;%= f.text_field :end_date %&gt;
        &lt;/div&gt;
      &lt;/div&gt;
        &lt;%= f.submit "Create", class: "btn btn-primary" %&gt;
      &lt;% end %&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>