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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060416/a196c85c/attachment.html
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:>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 > > >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails >_Kevin -- Posted with http://DevLists.com. Sign up and save your mailbox.
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 < devlists-rubyonrails@devlists.com> wrote:> > 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: > >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 > > > > > >_______________________________________________ > >Rails mailing list > >Rails@lists.rubyonrails.org > >http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _Kevin > > -- > Posted with http://DevLists.com. Sign up and save your mailbox. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060417/b372de57/attachment.html