I have a stock scaffold for a table that has a date field. When going to the edit page I get an ''invalid date'' error. I go to the ''Show'' page and the field is empty. If I replace date_select with datetime_select in _form.rhtml then the edit page does not generate an error. The date in the database is YYYY-MM-DD format. This is postgresql 8.0.3 and the latest stable version of ruby and rails. Freebsd 5.4. Seems like a bug, but could also be something I am just missing out of ignorance also. Any ideas?
snacktime wrote:> Seems like a bug, but could also be something I am just missing out of > ignorance also. Any ideas?AFAIK, you have to store dates with Postgres and Rails as type "timestamp". At least, that''s what I''m doing, and it seems to work fine. (I''d be delighted to know I''m wrong though!) ~Dave -- Dave Silvester Rent-A-Monkey Website Development Web: http://www.rentamonkey.com/
On 8/25/05, snacktime <snacktime-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have a stock scaffold for a table that has a date field. When > going to the edit page I get an ''invalid date'' error. I go to the > ''Show'' page and the field is empty. If I replace date_select with > datetime_select in _form.rhtml then the edit page does not generate an > error. The date in the database is YYYY-MM-DD format. This is > postgresql 8.0.3 and the latest stable version of ruby and rails. > Freebsd 5.4. > > Seems like a bug, but could also be something I am just missing out of > ignorance also. Any ideas? >Interesting. merchants.start_date.class = NilClass in the view (merchants is the table, start_date is the date column). A datetime column shows as class Time. Chris
On 8/25/05, Dave Silvester <dave-AJqNGCqIqVQ7cdpDWioORw@public.gmane.org> wrote:> snacktime wrote: > > Seems like a bug, but could also be something I am just missing out of > > ignorance also. Any ideas? > > AFAIK, you have to store dates with Postgres and Rails as type "timestamp". > > At least, that''s what I''m doing, and it seems to work fine. (I''d be delighted > to know I''m wrong though!)Well now it''s working and I can''t figure out what changed. At this point I''m assuming it was on my end until I prove otherwise. Chris
I ran into this as well, on Windows. The problem is the way Ruby formats Time.now.to_s OSX: Thu Aug 25 17:35:28 EDT 2005 Win: Thu Aug 25 17:35:28 Eastern Daylight Time 2005 Postgres is fine with the former (though pg people don''t like letters in timestamps), but not the latter. I was thinking about adding a patch to the postgresql_adapter but wanted to look into it more thoroughly. The relevant line is 263 return Time.now.to_s if value =~ /^\(''now''::text\)::(date|timestamp)/ Should be changed to: return Time.now.to_formatted_s(:db) if value =~ /^\(''now''::text\):: (date|timestamp)/ But there is more to the formatting that I haven''t gone through yet. M On Aug 25, 2005, at 4:57 PM, snacktime wrote:> On 8/25/05, snacktime <snacktime-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> I have a stock scaffold for a table that has a date field. When >> going to the edit page I get an ''invalid date'' error. I go to the >> ''Show'' page and the field is empty. If I replace date_select with >> datetime_select in _form.rhtml then the edit page does not >> generate an >> error. The date in the database is YYYY-MM-DD format. This is >> postgresql 8.0.3 and the latest stable version of ruby and rails. >> Freebsd 5.4. >> >> Seems like a bug, but could also be something I am just missing >> out of >> ignorance also. Any ideas? >> >> > > Interesting. merchants.start_date.class = NilClass in the view > (merchants is the table, start_date is the date column). A datetime > column shows as class Time. > > Chris > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >Matt Pelletier pelletierm-A1PILTyJ15gXhy9q4Lf3Ug@public.gmane.org