Forum: Ruby on Rails conditional updated_on update

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E98de78bb42013c488fe8aa9d77d2cb1?d=identicon&s=25 Steve Odom (Guest)
on 2006-04-17 00:25
(Received via mailing list)
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
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Kevin Olbrich (Guest)
on 2006-04-17 04:32
(Received via mailing list)
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 Odom wrote:
>counter_cache fields in acts_as_versioned, but can't ignore the updated_on
>_______________________________________________
>Rails mailing list
>Rails@lists.rubyonrails.org
>http://lists.rubyonrails.org/mailman/listinfo/rails
>


_Kevin
E98de78bb42013c488fe8aa9d77d2cb1?d=identicon&s=25 Steve Odom (Guest)
on 2006-04-17 13:16
(Received via mailing list)
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 Olbrich <
This topic is locked and can not be replied to.