# Help: Timestamp and Userstamp just stopped working

**URL:** <https://www.ruby-forum.com/t/help-timestamp-and-userstamp-just-stopped-working/68305>\
**Category:** Rails\
**Created:** [September 11, 2006, 4:41pm UTC](https://www.ruby-forum.com/t/help-timestamp-and-userstamp-just-stopped-working/68305 "2006-09-11T16:41:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sshingler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@sshingler](https://www.ruby-forum.com/u/sshingler)\
**Post date:** [September 11, 2006, 4:41pm UTC](https://www.ruby-forum.com/t/help-timestamp-and-userstamp-just-stopped-working/68305/1 "2006-09-11T16:41:16Z")

</div>

Uh oh. I am going to have a nightmare cleaning this up… It looks  
like timestamp and userstamp just stopped doing their thing.

Across several different models, I am seeing NULLs in my database for  
updated\_by and updated\_at and created\_at/etc.

Last night, I ran a migration that turned userstamp and timestamp off  
for two different models using the class attribute accessor. I have  
since restarted the production server so there should be no lasting  
effect from this. This problem is affecting models which had nothing to  
do with the migration.

Has anyone heard of something like this? I shudder to think of the mess  
this will create in my database today – a Monday – our heaviest day.  
I will have 500+ users through the site today plus my staff working on  
content all day. Ugh.

Any ideas where to look? I looked at the source for both of these and  
they are so simple I don’t see how they would just break like that.

Steven

---

<div class="post-metadata">

**Author:** ![sshingler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@sshingler](https://www.ruby-forum.com/u/sshingler)\
**Post date:** [September 11, 2006, 5:35pm UTC](https://www.ruby-forum.com/t/help-timestamp-and-userstamp-just-stopped-working/68305/2 "2006-09-11T17:35:17Z")

</div>

Steven Talcott S. wrote:

> Uh oh. I am going to have a nightmare cleaning this up… It looks  
> like timestamp and userstamp just stopped doing their thing.
> 
> Across several different models, I am seeing NULLs in my database for  
> updated\_by and updated\_at and created\_at/etc.

Okay, Lesson Learned!

Class attribute accessors can be called on an instance.

Do not call my\_model.record\_timestamps = false unless you want to turn  
this behavior off system-wide.

Two things:

1. the documentation on Timestamp should explain more clearly that  
setting applies to ActiveRecord::Base… not the class of your model and  
certainly not the instance.

2. I think this violates the “do the expected thing” principle. Does  
anyone agree?

Thank goodness for open source. I was able to contain the damage once I  
saw the problem and removed the offending line from my code.

May google save this and help someone else to avoid the same problem.  
Now, to clean up those NULLs…

Best,

Steven

---

<div class="post-metadata">

**Author:** ![sshingler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@sshingler](https://www.ruby-forum.com/u/sshingler)\
**Post date:** [September 11, 2006, 8:54pm UTC](https://www.ruby-forum.com/t/help-timestamp-and-userstamp-just-stopped-working/68305/3 "2006-09-11T20:54:55Z")

</div>

Steven Talcott S. wrote:

> Do not call my\_model.record\_timestamps = false unless you want to turn  
> this behavior off system-wide.

Interesting. What you want should certainly be possible.

This is what I found in the documentation  
([http://caboo.se/doc/classes/ActiveRecord/Timestamp.html](http://caboo.se/doc/classes/ActiveRecord/Timestamp.html)):

{snip}  
Keep in mind that, via inheritance, you can turn off timestamps on a  
per model basis by setting record\_timestamps to false in the desired  
models.

class Feed \< ActiveRecord::Base  
self.record\_timestamps = false  
# …  
end  
{snip}

Try doing this and see if it helps (on your development box 🙂

I’m not sure why doing “self.” would be different from what you did,  
though…?

Jeff

> **[Hey Daddio!](http://softiesonrails.com)**
>
> Home of Hey Daddio Software

---

<div class="post-metadata">

**Author:** ![sshingler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@sshingler](https://www.ruby-forum.com/u/sshingler)\
**Post date:** [September 12, 2006, 12:39am UTC](https://www.ruby-forum.com/t/help-timestamp-and-userstamp-just-stopped-working/68305/4 "2006-09-12T00:39:16Z")

</div>

Jeff C. wrote:

> Steven Talcott S. wrote:
> 
> > Do not call my\_model.record\_timestamps = false unless you want to turn  
> > this behavior off system-wide.
> 
> Interesting. What you want should certainly be possible.  
> …
> 
> I’m not sure why doing “self.” would be different from what you did,  
> though…?

I need to read up on the subtleties of “self.” since I am unclear on the  
implications. I have used it inconsistently in my code so far. Any  
good pointers? I will check pickaxe tomorrow.

Steven

---

<div class="post-metadata">

**Author:** ![sshingler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@sshingler](https://www.ruby-forum.com/u/sshingler)\
**Post date:** [January 19, 2007, 4:29pm UTC](https://www.ruby-forum.com/t/help-timestamp-and-userstamp-just-stopped-working/68305/5 "2007-01-19T16:29:50Z")

</div>

What ended up working for me was this:

class Weird \< ActiveRecord::Base  
def self.record\_timestamps; false; end  
end

Hope it helps,

AEM

On 9/11/06, Jeff [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

–  
Adrian Esteban Madrid

---

<div class="post-metadata">

**Author:** ![sshingler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@sshingler](https://www.ruby-forum.com/u/sshingler)\
**Post date:** [September 12, 2006, 3:13am UTC](https://www.ruby-forum.com/t/help-timestamp-and-userstamp-just-stopped-working/68305/6 "2006-09-12T03:13:32Z")

</div>

On 9/11/06, Steven Talcott S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > though…?
> 
> I need to read up on the subtleties of “self.” since I am unclear on the  
> implications. I have used it inconsistently in my code so far. Any  
> good pointers? I will check pickaxe tomorrow.

The best coverage of that topic that I’ve seen so far has been in Ruby  
for Rails.

– James
