[Unmaintained] User-centric voting system for Rails 3 applications
MIT License
= MakeVoteable
MakeVoteable is an extension for building a user-centric voting system for Rails 3 applications. It currently supports ActiveRecord models.
== Installation
add MakeVoteable to your Gemfile
gem 'make_voteable'
afterwards execute
bundle install
generate the required migration file
rails generate make_voteable
also add +up_votes+ and +down_votes+ columns to the voter (e.g. User) and voteable (e.g. Question) model migrations
add_column :users, :up_votes, :integer, :null => false, :default => 0 add_column :users, :down_votes, :integer, :null => false, :default => 0 add_column :questions, :up_votes, :integer, :null => false, :default => 0 add_column :questions, :down_votes, :integer, :null => false, :default => 0
migrate the database
rake db:migrate
== Usage
class Question < ActiveRecord::Base make_voteable end
class User < ActiveRecord::Base make_voter end
user.up_vote(question)
user.up_vote!(question)
user.down_vote(question)
user.down_vote!(question)
user.unvote(question)
user.unvote!(question)
question.up_votes
question.down_votes
user.up_votes
user.down_votes
question.votes
user.voted?(question)
user.up_voted?(question)
user.down_voted?(question)
voting = user.votings.first voting.up_vote? # true if up vote, false if down vote
voting = question.votings.first voting.up_vote? # true if up vote, false if down vote
== Testing
MakeVoteable uses RSpec for testing and has a rake task for executing the provided specs
rake spec
Copyright © 2010-2011 Kai Schlamp (http://www.medihack.org), released under the MIT license