Agile Web Development

Build it. Launch it. Love it.

acts_as_voteable

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

Vitals

Home http://www.juixe.com/techknow/index.php/2006/06/24/acts-as-voteable-rails-plugin/
Repository http://juixe.com/svn/acts_as_voteable/
License Rails' (MIT)
Tags Tag_red acts_as_voteable dfgfdg digg erter etyretre ls rateable retre tytr vote voting
Rating (53 votes)
Owner Juixe
Created 24 June 2006

Comments

  • Avatar
    asfd
    16 March 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
    
  • 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.

Add a comment