ajaxful-rating icon indicating copy to clipboard operation
ajaxful-rating copied to clipboard

no rating_average

Open badnaam opened this issue 15 years ago • 8 comments

I impleneted ajaxful rating on a Store model with 3 dimensions. I am caching rating average for each dimension as well as the overall average rating. The individual dimension rates are being saved and shown correctly (including average per dimension) and everything works fine except, the "rating_average" does not update (still at 0) even after multiple users have updated it for a specific record.

badnaam avatar Jun 10 '10 21:06 badnaam

Same problem for me.

TeuF avatar Jul 22 '10 19:07 TeuF

Copied from the readme file:

To use caching with dimensions, make sure you have a cache column defined for each dimension you want cached. So if you want to cache the spelling dimension, you’ll need to have a column called rating_average_spelling on the articles table. If you use a custom cache column name, follow the pattern cache_column_name_dimension_name to add cache columns for dimensions.

edgarjs avatar Aug 09 '10 02:08 edgarjs

I have no problem to cache dimensions, but I think what's about here, is to have a new column with the average rate:

rating_average_a = 4 rating_average_b = 3 rating_average_c = 3

rating_average = 3,33

Should we do it on app side or is it possible with ajaxful-rating ?

Thx,

TeuF avatar Aug 09 '10 07:08 TeuF

Oh so you want to have the average calculated with all dimensions? That's not possible in the plugin yet, it only calculates the average for each dimension.

edgarjs avatar Aug 09 '10 13:08 edgarjs

Yes that would be very useful. Is it on the "To Code" list ? ;)

TeuF avatar Aug 09 '10 14:08 TeuF

I think you're the first person that request it. So I will add it to the ToDo list, or if you want to add that feature and send me a pull request that'd be great, I haven't had too much time lately.

edgarjs avatar Aug 10 '10 14:08 edgarjs

I just comment the condition in has_many :rates_without_dimension and it work :) It would be cleaner with a condition "if dimension define then no :conditions => ...."

      if options[:dimensions].blank?
        has_many :rates_without_dimension, :as => :rateable, :class_name => 'Rate', :dependent => :destroy, :conditions => {:dimension => nil}
      else
        has_many :rates_without_dimension, :as => :rateable, :class_name => 'Rate', :dependent => :destroy
      end

Then it update rating_average

TeuF avatar Aug 11 '10 08:08 TeuF

I agree a rating average would be quite useful! Especially for my app!

angela1111 avatar Feb 02 '11 15:02 angela1111