Coder Social home page Coder Social logo

gabrielg / acts_as_rateable Goto Github PK

View Code? Open in Web Editor NEW
5.0 4.0 34.0 87 KB

Acts_as_rateable is a Ruby on Rails plugin which makes ActiveRecord models rateable through a polymorphic association and optionally logs which user rated which object. This plugin is used in production.

Home Page: http://xpnindustries.com

License: MIT License

Ruby 100.00%

acts_as_rateable's Introduction

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
=======

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 )

@post.average_rating #=> 4.0

@post.average_rating_round #=> 4

@post.average_rating_percent #=> 80

@post.rated_by?( current_user ) #=> rating || false

Post.find_average_of( 4 ) #=> array of posts

See acts_as_rateable.rb for further details!

Copyright (c) 2007 Ferenc Fekete, http://xpnindustries.com , released under the MIT license

acts_as_rateable's People

Contributors

azabaj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.