# Updating without auto timestamping

**URL:** <https://www.ruby-forum.com/t/updating-without-auto-timestamping/112114>\
**Category:** Rails\
**Created:** [August 15, 2007, 3:32pm UTC](https://www.ruby-forum.com/t/updating-without-auto-timestamping/112114 "2007-08-15T15:32:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iain\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6bbea6/32.png) [@Iain\_A](https://www.ruby-forum.com/u/Iain_A)\
**Post date:** [August 15, 2007, 3:32pm UTC](https://www.ruby-forum.com/t/updating-without-auto-timestamping/112114/1 "2007-08-15T15:32:33Z")

</div>

Hi,

Is there a way to stop the automatic timestamping. I have a model that  
has an updated\_on field. Its great that it updates on save however  
there is one operation i need to do that I dont want the updated\_on  
field to be set to the current time. Is there a way to stop this for  
this one operation?

Thanks

Iain A.

---

<div class="post-metadata">

**Author:** ![Iain\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6bbea6/32.png) [@Iain\_A](https://www.ruby-forum.com/u/Iain_A)\
**Post date:** [August 15, 2007, 3:59pm UTC](https://www.ruby-forum.com/t/updating-without-auto-timestamping/112114/2 "2007-08-15T15:59:38Z")

</div>

YrClass.record\_timestamps = false

# do the deed

YrClass.record\_timestamps = true

RSL

---

<div class="post-metadata">

**Author:** ![Iain\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6bbea6/32.png) [@Iain\_A](https://www.ruby-forum.com/u/Iain_A)\
**Post date:** [August 15, 2007, 4:19pm UTC](https://www.ruby-forum.com/t/updating-without-auto-timestamping/112114/3 "2007-08-15T16:19:40Z")

</div>

I tried this but get the error

NoMethodError in TopicController#show

undefined method `record\_timestamps=’ for #Topic:0xb6b88204

My code looks like this

@topic = Topic.find params[:id]  
@post\_pages, @posts = paginate :posts, :conditions=\>[“topic\_id = ?”,  
@topic.id], :per\_page=\>6  
@topic.viewed\_by @m  
@topic.increment ‘views’  
@topic.record\_timestamps = false  
@topic.save

---

<div class="post-metadata">

**Author:** ![Iain\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6bbea6/32.png) [@Iain\_A](https://www.ruby-forum.com/u/Iain_A)\
**Post date:** [August 15, 2007, 4:20pm UTC](https://www.ruby-forum.com/t/updating-without-auto-timestamping/112114/4 "2007-08-15T16:20:40Z")

</div>

Notice I said YrClass in my example. 😉

RSL

---

<div class="post-metadata">

**Author:** ![Iain\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6bbea6/32.png) [@Iain\_A](https://www.ruby-forum.com/u/Iain_A)\
**Post date:** [August 15, 2007, 4:26pm UTC](https://www.ruby-forum.com/t/updating-without-auto-timestamping/112114/5 "2007-08-15T16:26:40Z")

</div>

you can also use @topic.update\_without\_timestamps

Iain A. wrote:

> @topic.id], :per\_page=\>6
> 
> > > has an updated\_on field. Its great that it updates on save however

–  
Sincerely,

William P.

[http://www.billpratt.net](http://www.billpratt.net)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Iain\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6bbea6/32.png) [@Iain\_A](https://www.ruby-forum.com/u/Iain_A)\
**Post date:** [August 15, 2007, 4:36pm UTC](https://www.ruby-forum.com/t/updating-without-auto-timestamping/112114/6 "2007-08-15T16:36:42Z")

</div>

fyi, update/create\_without\_timestamps are private methods and should be  
used  
with caution [if at all]. a recent patch on edge removed a private  
method  
and when someone wrote a ticket about this, david said:

"The method is indeed a protected method and nodoc’ed to boot. In other  
words, an internal, implementational detail. But sounds like people are  
dipping into the forbidden cookie jar regardless. [  
[http://dev.rubyonrails.org/ticket/9086](http://dev.rubyonrails.org/ticket/9086)]

so I’d stick with the methodology i first mentioned. ymmv

RSL

---

<div class="post-metadata">

**Author:** ![Iain\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6bbea6/32.png) [@Iain\_A](https://www.ruby-forum.com/u/Iain_A)\
**Post date:** [August 15, 2007, 4:40pm UTC](https://www.ruby-forum.com/t/updating-without-auto-timestamping/112114/7 "2007-08-15T16:40:45Z")

</div>

My bad. I had simply noticed it before when scanning through methods()  
and noticed that it did indeed work. This is great to know, thanks.

Russell N. wrote:

> > > ```
> > > YrClass.record_timestamps = true
> > > 
> > > ```
> > > 
> > > >
> 
> >

–  
Sincerely,

William P.

[http://www.billpratt.net](http://www.billpratt.net)  
removed\_email\_address@domain.invalid
