Skip to content

DaveDeveloper/mongoid-rating

 
 

Repository files navigation

mongoid-rating

Rating solution for mongoid.

Usage

class User
    include Mongoid::Document
end

class Photo
    include Mongoid::Document
    include Mongoid::Rating
end

Do you want rate a photo as a user? Just type:

photo.rate(:by => user, :value => 10).save

or

photo.rate!(:by => user, :value => 10) # same as above

mongoid-rating store information about user and score in :rates field. Some useful methods:

photo.rated?(:by => user)   # should return true if user rate a photo
photo.rates_count
photo.rates_average
photo.rates_sum
photo.rates_percent # if you are using 1 for each rate up and 0 for each rate down this will give you a good percentage of likes.

Copyright © 2011 Łukasz Śliwa. See LICENSE.txt for further details.

About

Simple and powerful rating solution for mongoid

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%