Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Issue when adding a counter cache column

#2

The rate_average function was returning an infinity when using rates_count cached column. It was using the old number before the model updated it. I fixed it by adding the following code to the update_cached_average function:

rates(:refresh).size if self.respond_to?(:rates_count)

full function is now:

def update_cached_average
  if self.class.caching_average?
    rates(:refresh).size if self.respond_to?(:rates_count)
    send("#{self.class.options[:cache_column]}=", self.rate_average(false))
    save!
  end
end

end

Reported by Will Bunker · February 16th, 2009 @ 04:34 PM

State: resolved
Milestone: none
Assigned to: Edgar Suarez Edgar Suarez

Activity

  1. Edgar Suarez
    Edgar Suarez
    • Assigned user set to Edgar Suarez
    • State changed from new to resolved

    Thanks for the fix. :)

    March 5th, 2009 @ 06:48 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.