将评分功能添加到您的 Rails 应用程序和 ActiveRecord 模型的最佳方法。
Provides the best way to add rating capabilites to your Rails application with jQuery Raty plugin.
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.
Add the letsrate gem into your Gemfile
gem 'letsrate'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:install
rails 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.
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 /cars/1 %>
Speed :
Engine :
Price : If you need to change the star number, you should use star option like below.
Speed : 10 %>
Speed : 7 %>
Speed : You can use the rating_for_user helper method to show the star rating for the user.
Speed : 10 %>If you find bugs please open a ticket at https://github.com/muratguzel/letsrate/issues
暂无开放 Issues,或尚未同步最近议题。