Add this to your Gemfile:
and then run:
Generate a migration for the votes table with:
rails generate voting_booth:votes
Then, generate a migration for model you want to be votable, e.g.
rails generate voting_booth:votable BlogPost
and then run these migrations with
For any model that can be voted on, add
# app/models/blog_post.rb class BlogPost < ActiveRecord::Base votable end
For the model that should act as the voter (typically User), add
# app/models/user.rb class User < ActiveRecord::Base voter end
You can use the following helper methods in your views:
@votable is any object that has been marked as
You can override VotingBooth's configuration by creating an initializer, e.g.
# config/initializers/voting_booth.rb VotingBooth.positive_votes_only = true
The options that can be overrridden are specified in lib/voting_booth.rb