Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Acts_as_rateable is a rails plugin providing a rating interface for ActiveRecord models.

branch: master

This branch is 0 commits ahead and 0 commits behind master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 generators
Octocat-spinner-32 lib
Octocat-spinner-32 rails
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 CHANGELOG.rdoc
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 acts_as_rateable.gemspec
Octocat-spinner-32 init.rb
README.rdoc

Acts As Rateble

Acts_as_rateable is a rails plugin providing a rating interface for ActiveRecord models. It is released under the MIT license. The original plugin is used on cotcot.hu for article rating, sponsored quizzes, etc.

Features

  • Rating scores are recorded by user

  • Users can update previous ratings

  • Uses a polymorphic association to your model, so no changes to your existing models in the database are required

  • Stores computed score and number of ratings for efficient data access

  • Possibility to change range of the ratings (1..5 is default)

Installation

Install as gem (recommended)

Install as a gem:

$ sudo gem install mreinsch-acts_as_rateable

Then add the gem dependency in your config:

# config/environment.rb
config.gem "mreinsch-acts_as_rateable", :source => "http://gems.github.com", :lib => "acts_as_rateable"

Install as plugin

To install as a plugin, use:

$ ./script/plugin install git://github.com/mreinsch/acts_as_rateable.git

Example Usage

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)

@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.ratings_couunt          #=> 1

Post.find_top_rated           #=> top rated records

Optional you can specify the highest score using the :max_rating paramter as follows. The default for :max_rating is 5.

class Comment < ActiveRecord::Base
  acts_as_rateable :max_rating => 10
end

See acts_as_rateable.rb for further details!

Updating

Updating from Ferenc Fekete's acts_as_rateable v1.0

  1. Remove the old plugin, and install this version.

  2. Check your code and make sure you pass the user object instead of the user ID for the rate_it, rated_by? and rating_by methods.

  3. Generate an update migration using: ./script/generate acts_as_rateable_update1

  4. Run your test cases

Copyright

Copyright © 2007 Ferenc Fekete, xpnindustries.com , released under the MIT license

Copyright © 2009 mobalean LLC, www.mobalean.com

Something went wrong with that request. Please try again.