Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Date field not stored any more

#790

I have a simple application that stores tasks. A task has a due_date which is mapped on the DB as a date. === schema.rb === create_table "tasks", :force => true do |t|

t.date    "due_date"

...

Then loading a task from the db, changing the date, and storing it again, noting is changed:

D:\ruby\rails\app>ruby script\console Loading development environment (Rails 2.1.0)

t= Task.find(193) => # t.due_date= t.due_date + 1 => Tue, 12 Aug 2008 t.save => true t= Task.find(193)

=> #

The same code has worked in Rails 2.0.2, so I downgraded afterwards to 2.0.2 again.

Does any one knows the reason for that?

Reported by Markus Liebelt · August 9th, 2008 @ 12:52 PM

State: resolved
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Markus Liebelt
    Markus Liebelt

    Sorry for the formatting of the source. Here it is again:

    
    D:\ruby\rails\app>ruby script\console
    Loading development environment (Rails 2.1.0)
    >> t= Task.find(193)
    => #<Task id: 193, due_date: "2008-08-11">
    >> t.due_date= t.due_date + 1
    => Tue, 12 Aug 2008
    >> t
    => #<Task id: 193, due_date: "2008-08-12">
    >> t.save
    => true
    >> t= Task.find(193)
    => #<Task id: 193, due_date: "2008-08-11">
    

    August 9th, 2008 @ 12:57 PM

  2. Markus Liebelt
    Markus Liebelt

    After replacing the old code:

    @attributes["due_date"]= new_date

    Through:

    self[:due_date]= new_date

    everything was fine. So my old code had to change so that the change from Release 2.0 to 2.1 (don't use @attributes in your code) could work. I found the pattern self[:<att_name>] in the book "The Rails Way" by Obie Fernandez by accident (a lucky one).

    So the ticket should now be fixed

    November 15th, 2008 @ 05:49 PM

  3. DHH
    DHH
    • State changed from new to resolved

    November 16th, 2008 @ 08:42 PM