This project is archived and is in readonly mode.

#790 ✓resolved
Markus Liebelt

Date field not stored any more

Reported by Markus Liebelt | August 9th, 2008 @ 12:52 PM | in 2.x

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?

Comments and changes to this ticket

  • Markus Liebelt

    Markus Liebelt August 9th, 2008 @ 12:57 PM

    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">
    
  • Markus Liebelt

    Markus Liebelt November 15th, 2008 @ 05:49 PM

    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

  • DHH

    DHH November 16th, 2008 @ 08:42 PM

    • State changed from “new” to “resolved”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages