liftedmedia-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jun-05 22:13 UTC
validating votes w/ act_as_voteable
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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---