Rail plugin - provides the ability to filter by date of binary argument - I have my form set up in this way ...
& lt;% form_for @search do | F | & Gt%; & Lt;% = f.label: start% & gt; & Lt;% = f.select: due_at_after, [[['', '']], ['Nov', '2009-11-01'. T_DATE), ['December', '2009-12-01' To_date]]%> & lt; Br> & Lt;% = f.label: end% & gt; & Lt;% = f.select: due_at_before, [[['', '']], ['Dec', '2009-12-01' 'T_adet'], ['Jan', '2010-01-01 'To_date]]%> & Lt;% = f.submit 'Search'% & gt; & Lt;% end% & gt;
However, I am returning the date from the search item generated in the controller ...
@search = Task.with_member (current_user). Search (Param [: Search])
It looks like a date is generating the ultimate
{: due_at_after => Saturn, 31 Oct 2009 20:00:00 EDT-04: 00}
With two formats, this form will not show drop-down as selected. SearchLock The format of the object also uses timezone adjust time.
Any ideas on how to handle it?
A big part of your problem is happening because you are converting strings into wires, and back To date the dates I believe you can do as much as you want.
The HTML form is not really the date of "understanding" - they simply "understand" the wire. Therefore it is okay to pass the stars instead of these stars. In other words, it is ok to remove to_date
.
& lt;% form_for @search do | F | & Gt%; & Lt;% = f.label: start% & gt; & Lt;% = f.select: due_at_after, ['Nov', '2009-11-01'], ['December', '2009-12-01']] ,: include_blank => True% & gt; & Lt; Br / & gt; & Lt;% = f.label: end% & gt; & Lt;% = f.select: due_at_before, [['December', '2009-12-01'], ['Jan', '2010-01-01']] ,: include_blank = & gt; True% & gt; & Lt;% = f.submit 'Search'% & gt; & Lt;% end% & gt;
In addition, I like using : include_blank = & gt; Instead of
[[,, '', '']]
(more human-readable, in my opinion), and I have a closed & lt; Br / & gt;
Tags (standard HTML stuff - maybe you have made a typo?).
By the way, if you want to specify a date, you can use the date constructor. Compared to writing and parsing it on date, it is faster to write and faster to execute.
# Date (2009,11,1) Fast, Small, and Equivalent Date (2009, 11, 21) == '2009-11-01'. Toadet # - & gt; True
No comments:
Post a Comment