I poked around and don't know if it is a bug or feature ;-).
This works correctly:
<%= select_tag(:mydate, options_for_select( %w{ 2007-08-22 2007-08-29
2007-09-05 }, params['mydate'])) %>
Chosen item is selected when form is submitted
But this will not:
@pubdates is an array of dates from the DB same as above
@pubdates = Pubdates.find(:all, :order=>"pubdate").map {|u|
[u.pubdate] }
This works correctly:
<%= select_tag(:mydate, options_for_select( %w{ 2007-08-22 2007-08-29
2007-09-05 }, params['mydate'])) %>
Chosen item is selected when form is submitted
But this will not:
@pubdates is an array of dates from the DB same as above
@pubdates = Pubdates.find(:all, :order=>"pubdate").map {|u|
[u.pubdate] }
What I found was that ActiveRecord maps the list of dates to a
different data type than the params that it is comparing to(this is a
guess).
yes, if you store that field in the db as date or datetime, AR will
return it as a Date object. AR will return the column's data cast to
the appropriate ruby type. i'm pretty sure all form params will be
strings by default.