I need to take in a Date Range from the UI, retrieve the records within that range and plot a graph. This is the relevant section in my Rails view.
<span>
<%= check_box_tag :applyRange, @params[:applyRange]%>
From
<%= select_date Time.now, :prefix=>"fromDate" %>
To
<%= select_date Time.now, :prefix=>"toDate" %>
</span>
Back on the controller/action side, this is what I had to do to reconstruct the date values back (hack hack puts hack puts hack...)
fromDate = Date.civil params[:fromDate]["year"].to_i, params[:fromDate]["month"].to_i, params[:fromDate]["day"].to_i
This just feels wrong. I'll probably have the fields have blanks too.. in which case to_i is bound to barf. This looks like something that must have been done a zillion times before.. So looking for a good recipe for this. I spent the better part of the last hour trying to figure out this quirky rails helper.