The best way to add rating capabilities to your rails application and your activerecord models.
Clone or download
Pull request Compare This branch is 3 commits ahead, 9 commits behind muratguzel:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Letsrate Rating Gem

Provides the best way to add rating capabilites to your Rails application with jQuery Raty plugin.

Build Status Dependency Status Code Climate


Find it at



Add the letsrate gem into your Gemfile

gem 'letsrate'


rails g letsrate User

The 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)


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:install
rails g devise user

rails g letsrate user # => user is the model generated by devise

This generator will create Rate and RatingCache models and link to your user model.


I suppose you have a car model

rails g model car name:string

You should add the letsrate_rateable function with its dimensions option. You can add multiple dimensions.

class Car < ActiveRecord::Base
  letsrate_rateable "speed", "engine", "price"

Set :can_change option if you want to allow users to change their ratings

class Car < ActiveRecord::Base
  letsrate_rateable "speed", "engine", "price", :can_change => true

Then you need to add a call letsrate_rater in the user model.

class User < ActiveRecord::Base


There 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 %>

Use :readonly option if you need only show rating, without ability to set rating

Speed : <%= rating_for @car, "speed", :readonly => true %>
Speed : <%= rating_for_user @car, current_user, "speed", :readonly => true %>


If you find bugs please open a ticket at