def cancel_vote(vid, vtid)
Vote.find(:first, :select => "id", :conditions =>
['vote_item_id = ? AND vote_topic_id = ? AND user_id = ?', vid, vtid,
self.id]).destroy
end
When a vote is created the votes_count in VoteItem and VoteTopic are
updated correctly. But when a vote is destroyed or cancelled the
counter is not decremented.
['vote_item_id = ? AND vote_topic_id = ? AND user_id = ?', vid, vtid,
self.id]).destroy
end
When a vote is created the votes_count in VoteItem and VoteTopic are
updated correctly. But when a vote is destroyed or cancelled the
counter is not decremented.
Stab in the dark: because your select clause only includes id, rails
doesn't know the user_id/vote_item_id/vote_topic_id and so doesn't
know which user/vote_item/vote_topic to update.