Updating without auto timestamping

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 Adams

YrClass.record_timestamps = false

do the deed

YrClass.record_timestamps = true

RSL

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

Notice I said YrClass in my example. :wink:

RSL

you can also use @topic.update_without_timestamps

Iain Adams wrote:

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]

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

RSL

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 Norris wrote: