0.0
No commit activity in last 3 years
No release in over 3 years
Clean, powerful, customizable, simple, configurable, gem for displaying and handling ratings, likes, or stars for ActiveRecord model.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.3
>= 0
 Project Readme

SelfRateable Code Climate

Clean, powerful, customizable, simple, configurable, gem for displaying and handling ratings, likes, and feedbacks for ActiveRecord model. People!!! Please provide your feedbacks what functionality to add on the issues page. I'm open to whatever questions for improving this gem.

Installation

  • Add this line to your application's Gemfile:

    gem 'self_rateable'

  • Execute:

    $ bundle

  • Or install it yourself as:

    $ gem install self_rateable

Usage

Make you ActiveRecord model self rateable:

The default type is :likes

class Model < ActiveRecord::Base
  self_rateable by: :class_name_of_AR_model_that_can_rate
end

Rates philosophy as in facebook & vk (like/unlike)

class Model < ActiveRecord::Base
  self_rateable by: :class_name_of_AR_model_that_can_rate, type: :likes
end

Rate:

object.like object_of_AR_model_that_can_rate

Stars rates diapasone 1..5 (as on movies)

class Model < ActiveRecord::Base
  self_rateable by: :class_name_of_AR_model_that_can_rate, type: :stars
end

Rate:

object.rate object_of_AR_model_that_can_rate, count_of_stars

Rates philosophy as in stackoverflow (+1 vs -1)

class Model < ActiveRecord::Base
  self_rateable by: :class_name_of_AR_model_that_can_rate, type: :points
end

Rate:

object.vote object_of_AR_model_that_can_rate, bool

This vote method returns false if object-of-AR-model-that-can-rate has already voted once. You can capture that output to show some messages.

(If true it adds 1 point if false it decreases 1 point)

Run rake task to prepare and update your database:

rake self_rateable

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request.

What to do?

  1. Cover with tests
  2. Create generators for templates to render on UI with images and styling of different types of ratings.
  3. Improve flexibility.