# Validating votes w/ act\_as\_voteable

**URL:** <https://www.ruby-forum.com/t/validating-votes-w-act-as-voteable/106055>\
**Category:** Rails\
**Created:** [June 6, 2007, 12:14am UTC](https://www.ruby-forum.com/t/validating-votes-w-act-as-voteable/106055 "2007-06-06T00:14:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 6, 2007, 12:14am UTC](https://www.ruby-forum.com/t/validating-votes-w-act-as-voteable/106055/1 "2007-06-06T00:14:23Z")

</div>

I’m have trouble implementing a uniqueness check w/ act\_as\_voteable  
plugin. The 2 approaches I’ve taken:

vote.rb (plugin dir): I tried adding the line  
“validates\_uniqueness\_of” to the votes.rb but there seems to be no  
affect

albums.rb (model dir): the validation does not pass but the vote is  
being added regardless.

How would I add a model level validation to the act\_as\_voteable  
plugin?

## voting action

```
    vote = Vote.new(:vote => true, :user_id => @current_user.id)

```

## albums = Albums.find(params[:id]) albums.votes \<\< vote

## vote.rb

## class Vote \< ActiveRecord::Base belongs\_to :user def self.find\_votes\_cast\_by\_user(user) find(:all, :conditions =\> [“user\_id = ?”, user.id], :order =\> “created\_at DESC” ) end end

thanks Dan
