Cannot save Date field

Hi,

I have a table which has a column called due_date. Datatype of this
column in
mySQL is “Date”. Here is what I extracted from schema.rb

t.column “due_date”, :date

My fixture tasks.yml file has the following line

due_date: 07/17/2006

My test_task.rb has the following line

assert_equal “07/17/2006”, @task.due_date

When I run the test, it fails. It said
testcreate(TaskTest) [test/unit/task_test.rb:16]
<“07/17/2006”> expected by was

Does anyone know why I cannot save the date field?
The format of the date passed from my page is “%m/%d/%Y”.

Thanks.

Arnold.

A few things:

On 7/29/06, Arnold Ng [email protected] wrote:

due_date: 07/17/2006
Use iso format. due_date: 2006-07-17.

Does anyone know why I cannot save the date field?
The format of the date passed from my page is “%m/%d/%Y”.

You should expect a Date object back, not a string.

assert_equal Date.new(2006, 7, 17), @task.due_date

Have a look at my validates_date_time plugin, it will allow you to
accept a variety of different date formats.

http://svn.viney.net.nz/things/rails/plugins/validates_date_time

-Jonathan.

Jonathan,

Thanks for your information. Let me try it out.

Arnold.

Jonathan V. wrote:

A few things:

On 7/29/06, Arnold Ng [email protected] wrote:

due_date: 07/17/2006
Use iso format. due_date: 2006-07-17.

Does anyone know why I cannot save the date field?
The format of the date passed from my page is “%m/%d/%Y”.

You should expect a Date object back, not a string.

assert_equal Date.new(2006, 7, 17), @task.due_date

Have a look at my validates_date_time plugin, it will allow you to
accept a variety of different date formats.

http://svn.viney.net.nz/things/rails/plugins/validates_date_time

-Jonathan.