Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
|
|
12 years ago | |
|---|---|---|
| .. | ||
| app | 12 years ago | |
| bin | 12 years ago | |
| config | 12 years ago | |
| lib | 12 years ago | |
| Gemfile | 12 years ago | |
| MIT-LICENSE | 12 years ago | |
| README.md | 12 years ago | |
| Rakefile | 12 years ago | |
| seems_rateable.gemspec | 12 years ago | |
Star rating gem for Rails application using jQuery plugin jRating
Demo application, requires to sign up before rating
Add this line to your application's Gemfile:
gem 'seems_rateable'
And then execute:
$ bundle
Or install it yourself as:
$ gem install seems_rateable
$ rails generate seems_rateable:install
Generator creates migration files, javascript files and initializer
Require javascript files by adding this line to application.js
#application.js
//= require_directory ./rateable
Add seems_rateable to routes.rb file
Include stylesheet adding <%= seems_rateable_stylesheet %> to your layout header
Also make sure you have an existing current_user helper method
Don't forget to run
$ rake db:migrate
To prepare model add seems_rateable to your rateable model file. You can also pass a hash of options to
customize the functionality
:dimensionsArray of dimensions e.g :dimensions => [:quality, :quantity] :allow_updateAllowing user to re-rate his own ratings, default set to false e.g :allow_update=> trueclass Post < ActiveRecord::Base
seems_rateable :allow_update => true, :dimensions => [:quality, :length]
end
To access object's rates use rates method, to get dimension rates pass an argument eg :
@object.rates
@object.rates(:quality)
@object.rates(:quantity)
This also applies to cached average rating e.g
@object.average
@object.average(:quality)
@object.average(:quantity)
And to object's raters e.g
@object.raters
@object.raters(:quality)
@object.raters(:quantity)
To track user's given ratings add seems_rateable_rater to your rater model.
If your rater class is not "User"(e.g "Client" or "Customer") change configuration in initializer generated by this engine.
Now you can access user's ratings by @user.ratings_given
To display star rating use helper method rating_for in your view
#index.html.erb
rating_for @post
rating_for @post, :dimension => :quality, :class => 'post', :id => 'list'
rating_for @post, :static => true
You can specify these options :
:dimensionThe dimension of the object:staticSet to true to display static star rating, default false:classClass of the div, default set to 'rateable':idID of the div e.g :id => "info", default nilTo edit the javascript options locate rateable.js file in /app/assets/javascripts/rateable/.
The javascript options are explained directly in the file
git checkout -b my-new-feature)git commit -am 'Add some feature')git push origin my-new-feature)软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...
JavaScript Ruby HTML+ERB CSS SVG other