Plugins - acts_as_voteable

StarAdd to favorites

Adds acts_as_voteable functionality to ActiveRecord models, which allows you to associate a vote for or against a model instance.

Juixe

http://www.juixe.com/techknow/index.php/2006/06/24/acts-as-voteable-rails-plugin/

http://juixe.com/svn/acts_as_voteable/

Rails' (MIT)

  • Currently 3.9/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Model

Tags

Comments

Add a comment
Matt 10 May 2007

I found this after writing an almost identical plugin myself. One difference is that I used validatesuniquenessof :voterid, :scope => [:voteabletype, :voteable_id] in my Vote model to make sure that a particular user can't vote more than once, which I think is a good way to do it. Stop them at the model in case you accidentally leave a hole in your controller.

asfd 16 Mar 2007

the logic to check if a user has voted uses a loop, its better to just let the db to it...

    def vote_for?(user)
      vote = Vote.find_by_user_id_and_voteable_type_and_voteable_id(user.id, self.class.name, self.id)
      return false = vote == nil
      return true
    end

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?