forked from gabrielg/acts_as_rateable
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael Reinsch
committed
Jul 20, 2009
1 parent
69d4736
commit c4e8b11
Showing
3 changed files
with
20 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
rdoc | ||
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,33 @@ | ||
Acts As Rateble | ||
============= | ||
= Acts As Rateble | ||
|
||
Acts_as_rateable is a plugin released under the MIT license. | ||
It makes activerecord models rateable through a polymorphic association and optionally logs which user rated which model. | ||
In this case, one user can rate an object once. Used on cotcot.hu for article rating, sponsored quizzes, etc. | ||
|
||
|
||
Example | ||
======= | ||
= Example | ||
|
||
Install the plugin into your vendor/plugins directory, insert 'acts_as_rateable' into your model, then restart your application. | ||
|
||
class Post < ActiveRecord::Base | ||
|
||
acts_as_rateable | ||
|
||
end | ||
|
||
Now your model is extended by the plugin, you can rate it ( 1-# )or calculate the average rating. | ||
|
||
@post.rate_it( 4, current_user.id ) | ||
class Post < ActiveRecord::Base | ||
acts_as_rateable | ||
end | ||
|
||
@post.average_rating #=> 4.0 | ||
Now your model is extended by the plugin, you can rate it (1-#) or calculate the average rating. | ||
|
||
@post.average_rating_round #=> 4 | ||
@post.rate_it(4, current_user) | ||
|
||
@post.average_rating_percent #=> 80 | ||
@post.average_rating #=> 4.0 | ||
@post.average_rating_round #=> 4 | ||
@post.average_rating_percent #=> 80 | ||
@post.rated_by?(current_user) #=> true | ||
@post.rating_by(current_user) #=> 4 | ||
|
||
@post.rated_by?( current_user ) #=> rating || false | ||
|
||
Post.find_average_of( 4 ) #=> array of posts | ||
Post.find_average_of(4) #=> array of posts | ||
|
||
See acts_as_rateable.rb for further details! | ||
|
||
= Copyright | ||
|
||
Copyright (c) 2007 Ferenc Fekete, http://xpnindustries.com , released under the MIT license | ||
|
||
Copyright (c) 2009 mobalean LLC, http://www.mobalean.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters