-
Notifications
You must be signed in to change notification settings - Fork 127
Quickstart guide
gem install ajaxful_rating
script/generate ajaful_rating <YourAlreadyCreatedUserModelClassName>
The generator takes only one argument, which is the name of your user model. For this of course, you should have already created it.
Also, this command will generate the next necessary files:
- app/models/rate.rb
- db/migrate/xxxxxxxxxxxx_create_rates.rb
- public/images/ajaxful_rating/star.png
- public/images/ajaxful_rating/star_small.png
- public/stylesheets/ajaxful_rating.css
Within the <head></head>
tags of your layout, include the next lines:
You need to add a member to your model rest route, for example if you want your Car
model be rateable:
And finally, add the action method to handle the ajax request in your cars controller:
The explanation of the methods used here can be found in the Ajaxful controller page.
To add a model the capability of receive ratings, add the following line in your model class:
And in your user model, the ability to rate resources:
And in your views, to display the nice hover stars:
That’s it.
If you want a model to receive ratings for different “features”, like a car can be rated by its speed, price and beauty, you could use the :dimensions
option in the ajaxful_rateable
call. This option is explained at detail in the Dimensions page.