#614 invalid
Michael Guterl

dm-timestamps doesn't set created_at/created_on when no other properties are set

Reported by Michael Guterl | October 26th, 2008 @ 01:15 PM

I've come across a strange edge case when using dm-timestamps with a very simple model.

A test case is available here: http://pastie.org/300876

After some discussion with namelessjon on IRC here's the gist of things...

dm-timestamps attempts to set the timestamp fields only when the model is dirty. In the case of a model with no other attributes, the timestamps are not applied/saved due to dirty? returning false.

This problem can be alleviated by also checking if the model is dirty or a new_record. Adding the simple condition fixes the problem, but it also will set the updated_at/on fields also. This behavior would be consistent with ActiveRecord, but I'm not sure if that is the desired behavior...

I know my example is rather contrived, but I guess the real question is what is the actual intended behavior?

Comments and changes to this ticket

  • kristian

    kristian October 31st, 2008 @ 07:35 AM

    • Tag set to dm-timestamp

    actually any model with timestamps on which you can do

    MyModel.create()

    will not set the created_at properties. even in such a case I would expect the created, updated properties to be set in the database. actually I declare them usually as nullable=>false

    just a users opion ;)

  • kristian

    kristian November 1st, 2008 @ 05:11 PM

    actually it is a duplicate of #601

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) December 1st, 2008 @ 11:41 AM

    • Assigned user cleared.
    • State changed from “new” to “invalid”

    Marking this as invalid because it's a duplicate of #601, which contains more information and a patch under discussion.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

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

People watching this ticket

Pages