Ajax Star Rating In form RoR
In my RoR 3 projec开发者_运维百科t, I am trying to have a way of doing reviews for a model. Kind of like amazon, where the user can review a product as well as rate it. For this, I chose ajaxful-rating & acts_as_commentable plugins. However, I am running into the problem that when the user clicks on a star rating (via ajaxful-rating), the rate function, automatically adds the db row to the "rate" table, therefore it will be able to exist without a comment attached to it which is not what I want. It also doesn't seem logical to rewrite the ajaxful functionality and I have a feeling that this functionality should exist somewhere out there, but I cant find any gem or plugin out there.
Has anyone out there done something like this before?
Why not link the rating model to the comment in a one to one relationship, then you can calculate the product's average rating by averaging the ratings of all of the comments on that product?
精彩评论