From a9b65794ba867b09a1b2c5453076da03b5ea49c2 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Mon, 13 Apr 2015 13:41:02 -0300 Subject: [PATCH] vote_plugin: allow anonymous votes --- lib/noosfero/vote_ext.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/noosfero/vote_ext.rb b/lib/noosfero/vote_ext.rb index 12f78f6..be349ca 100644 --- a/lib/noosfero/vote_ext.rb +++ b/lib/noosfero/vote_ext.rb @@ -2,6 +2,10 @@ require_dependency 'models/vote' class Vote - validates_uniqueness_of :voteable_id, :scope => [:voteable_type, :voter_type, :voter_id] + validates_uniqueness_of :voteable_id, :scope => [:voteable_type, :voter_type, :voter_id], :if => :allow_duplicated_vote? + + def allow_duplicated_vote? + voter.present? + end end -- libgit2 0.21.2