I have the following model that uses the plugin act_as_voteable:
class Video < ActiveRecord::Base
attr_accessible :url, :title, :description, :vote_count
validates_presence_of :url, :title, :description
I also have an observer for Vote model, so each time a user cast a vote to a video, or other content, I will update some info, including the vote_count on video model or other content. The code that runs each time a vote is created is:
def update_user_points_and_votes_count(vote, factor)
content_clazz = Kernel.const_get(vote.voteable_type)
Basically, I will update vote_count when a vote is casted to a video, or other kind of content that act_as_voteable.
The problem is that the instruction content.save! raises a validation exception on :url (in the list of validates_presence_of). I think that it will fail also on the other attributes in the list of validates_presence_of.
What I’m missing?