Skip to content
This repository has been archived by the owner on Feb 5, 2021. It is now read-only.

no rating_average #30

Open
badnaam opened this issue Jun 10, 2010 · 8 comments
Open

no rating_average #30

badnaam opened this issue Jun 10, 2010 · 8 comments

Comments

@badnaam
Copy link

badnaam commented Jun 10, 2010

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.

@TeuF
Copy link

TeuF commented Jul 22, 2010

Same problem for me.

@edgarjs
Copy link
Owner

edgarjs commented Aug 9, 2010

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.

@TeuF
Copy link

TeuF commented Aug 9, 2010

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,

@edgarjs
Copy link
Owner

edgarjs commented Aug 9, 2010

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.

@TeuF
Copy link

TeuF commented Aug 9, 2010

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

@edgarjs
Copy link
Owner

edgarjs commented Aug 10, 2010

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.

@TeuF
Copy link

TeuF commented Aug 11, 2010

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

@angela1111
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants