edgarjs / ajaxful-rating

Provides a simple way to add rating functionality to your application.
http://rdoc.info/projects/edgarjs/ajaxful-rating
417 stars 127 forks source link

Having a static rating and user rating on the same view #69

Closed brousalis closed 12 years ago

brousalis commented 12 years ago

When I do something like

= ratings_for @guide, :static      
= ratings_for @guide, :show_user_rating => true

The ratings match each other after you vote with the user rating, since the user rating updates itself to the average rating. Is there anyway to turn this off so I can put the average rating on the same view as the voting?

Thanks!

edgarjs commented 12 years ago

you mean the :show_user_rating updates itself with the average? It should stay with the user vote.

brousalis commented 12 years ago

Sorry, not even sure my original issue is in english. Damn late nights.

And yeah, it doesn't seem to stay with the user vote. I figured out my issue. Following solutions provided on https://github.com/edgarjs/ajaxful-rating/issues/56 to figure the rest out. Nothing wrong with gem :) Just the logic behind what I was trying to do.

brousalis commented 12 years ago

I ended up doing this in rate.js.erb:

$("#rates #<%= @guide.wrapper_dom_id(params) %>").html("<%= escape_javascript(ratings_for(@guide, params.merge(:wrap => false))) %>"); 
$("#average #<%= @guide.wrapper_dom_id(params) %>").html("<%= escape_javascript(ratings_for(@guide, params.merge(:show_user_rating => false, :force_static => true, :wrap => false))) %>"); 

Worked like a charm :)