Rails Plugin for Multiple Ratings Per Model?
I'm looking to add the capability of rating a model I have under several different categories like "Knowledgeable" "Organized", etc. Is there a plugin that will allow me to do this, a开发者_JAVA百科nd maybe even have a cool x/5 stars graphical representation as well?
I don't think any of the ratings plugins support this, but you could make a model called CatgoricalRating
that is setup like this:
#This table has model_id, rating_category, and columns to support the rating system
class CatgoricalRating < ActiveRecord::Base
belongs_to :model
acts_as_rateable # (or any other rating plugin)
end
class Model < ActiveRecord::Base
has_many :categorical_ratings
end
Then any model can have any number of ratings through that relationship
You could even make it a has_many :through
where one model represents the categories, and the 'join' model associates one model with one category and also contains the rating information.
精彩评论