Topic: validate_uniqueness_of + act_as_voteable

I'm have trouble implementing a uniqueness check w/ act_as_voteable plugin

I tried adding the line to the votes.rb in the plugin directory but nothing happens

How would I add a model level validation to the act_as_voteable plugin?

class Vote < ActiveRecord::Base
  belongs_to :user

  validates_uniqueness_of :voteable_id, :scope => :user_id

  def self.find_votes_cast_by_user(user)
      :conditions => ["user_id = ?",],
      :order => "created_at DESC"

Re: validate_uniqueness_of + act_as_voteable

Should work on scope? I use that technique.

Actually, I know your problem. I had the same thing, it's misleading.

Try this instead:

validates_uniqueness_of :user_id, :scope => :some_id 
# some_id (of the model that enables votes, post_id for e.g)

Last edited by DFischer (2007-06-06 03:35:57) - Personal Web-Technology-Blog, Los Angeles.