title: How to retrive and show the records of given date range in rails
body: <p>In my application I want to select the date range using jquery datepicker and retrive records of that date range and show them in report. I want the jquery datepicker values to be passed to the query in my controller.</p>
  
  <p>My form (dateFilter.html.erb)for datepicker values is as below: </p>
  
  <pre><code>&lt;%= form_tag({:controller =&gt; 'expenses', :action =&gt; 'dateFilter'}, :class =&gt;"datepicker") do %&gt;
  &lt;%= label_tag("Start Date") %&gt; &lt;br /&gt;
  &lt;%= text_field_tag(:start_date) %&gt;
  &lt;%= label_tag("End Date") %&gt; &lt;br /&gt;
  &lt;%= text_field_tag(:end_date) %&gt;
  &lt;%= submit_tag "Submit" %&gt;
  &lt;% end %&gt; 
  </code></pre>
  
  <p>expenses_controller is as below :</p>
  
  <pre><code> def dateFilter  
     @expenses = current_user.expenses.where(:created_at =&gt; (params[:start_date]..params[:end_date]))  
   end
  </code></pre>
  
  <p>Here is application.js :</p>
  
  <pre><code>$(document).ready(function() {
  
     $("#start_date").datepicker();
     $("#end_date").datepicker();
  
  });
  </code></pre>
  
  <p>Any help would be highly appreciated.</p>