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

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

Any suggestions?

Thanks very much,


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]


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


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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs