+1 for a public API

I've been using this :( http://gist.github.com/247472


On Wed, Dec 2, 2009 at 20:23, dasil003 <[email protected]> wrote:

> Has there ever been discussion of adding a method to recalculate
> counter cache values?
>
> This seems like it would be useful both for adding counter caches to
> existing tables, and also for fixing things up when direct SQL
> manipulations are used (performance reasons in my case).
>
> There are actually two parts to the problem.  The simple part is that
> the update_counters only supports incremental change, so doing a full
> reset would require some awkward arithmetic.
>
> The more complex part is using the association reflections to
> calculate the actual value automatically.  Doing so would require the
> participation of both the belongs_to reflection *and* the has_many
> reflection, which I can see being a bit smelly given the fact that the
> counter cache currently works without the need for has_many to be
> declared at all.  However I think it's utility might outweigh the
> complexity...
>
> What do you guys think?
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-core%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-core?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.


Reply via email to