muratguzel/letsrate
{ "createdAt": "2012-08-28T19:28:22Z", "defaultBranch": "master", "description": "The best way to add rating capabilities to your rails application and your activerecord models.", "fullName": "muratguzel/letsrate", "homepage": "http://letsrate.herokuapp.com", "language": "JavaScript", "name": "letsrate", "pushedAt": "2018-10-05T22:03:10Z", "stargazersCount": 201, "topics": [], "updatedAt": "2025-08-15T09:45:37Z", "url": "https://github.com/muratguzel/letsrate"}Letsrate Rating Gem
Section titled “Letsrate Rating Gem”Provides the best way to add rating capabilites to your Rails application with jQuery Raty plugin.
Future Of The Letsrate Gem
Section titled “Future Of The Letsrate Gem”This gem will be updated on very early 2015 with many features. :) You can send me a message if you want to be a part of it.
Instructions
Section titled “Instructions”Install
Section titled “Install”Add the letsrate gem into your Gemfile
gem 'letsrate'Generate
Section titled “Generate”rails g letsrate UserThe generator takes one argument which is the name of your existing devise user model UserModelName. This is necessary to bind the user and rating datas. Also the generator copies necessary files (jquery raty plugin files, star icons and javascripts)
Example:
Suppose you will have a devise user model which name is User. The devise generator and letsrate generator should be like below
rails g devise:installrails g devise user
rails g letsrate user # => user is the model generated by deviseThis generator will create Rate and RatingCache models and link to your user model.
Prepare
Section titled “Prepare”I suppose you have a car model
rails g model car name:stringYou should add the letsrate_rateable function with its dimensions option. You can add multiple dimensions.
class Car < ActiveRecord::Base letsrate_rateable "speed", "engine", "price"endThen you need to add a call letsrate_rater in the user model.
class User < ActiveRecord::Base letsrate_raterendThere is a helper method which name is rating_for to add the star links. By default rating_for will display the average rating and accept the new rating value from authenticated user.
<%# show.html.erb -> /cars/1 %>
Speed : <%= rating_for @car, "speed" %>Engine : <%= rating_for @car, "engine" %>Price : <%= rating_for @car, "price" %>If you need to change the star number, you should use star option like below.
Speed : <%= rating_for @car, "speed", :star => 10 %>Speed : <%= rating_for @car, "engine", :star => 7 %>Speed : <%= rating_for @car, "price" %>You can use the rating_for_user helper method to show the star rating for the user.
Speed : <%= rating_for_user @car, current_user, "speed", :star => 10 %>Feedback
Section titled “Feedback”If you find bugs please open a ticket at https://github.com/muratguzel/letsrate/issues


