Conditional updated_on update

Hi list,

I’ve got some counter_caches in a model. When these get incremented -
say on
a page view - my updated_on column also gets updated. How can I
conditionally not update updated_on if just these counter_cache columns
change?

The problem with that is that I am using acts_as_versioned which clones
the
record each time updated_on changes. I am successfully ignoring the
counter_cache fields in acts_as_versioned, but can’t ignore the
updated_on
column because I need to use that column in my versioned model.

Any suggestions?

Thanks very much,

Steve
http://www.smarkets.net

Perhaps extracting the counter_cache’d part out into a separate model
would help. You could set up a has_one/belongs_to relationship with the
original model and just use it to hold the versioned information.

You could probably also set up has_many :through relationships to retain
the association functions. If you post a sample schema, I could help
you sort that out if this isn’t clear.

On Sunday, April 16, 2006, at 5:23 PM, Steve O. wrote:

counter_cache fields in acts_as_versioned, but can’t ignore the updated_on


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

_Kevin

Thanks Kevin. I’m going to be playing around with your suggestion the
next
couple of days. Hopefully less than that if I implement it properly.

Steve

On 17 Apr 2006 02:31:07 -0000, Kevin O. <