Hi, I missed on line in the second block of code: def update_user_points_and_votes_count(vote, factor) content_clazz = Kernel.const_get(vote.voteable_type) #missing content = content_clazz.fin(vode.voteable_id)
content.vote_count +=1*factor content.save! ... ... end Thank you On Fri, May 21, 2010 at 12:47 AM, Jonhy Pear <jonhy.p...@gmail.com> wrote: > Hi, > > I have the following model that uses the plugin act_as_voteable: > > class Video < ActiveRecord::Base > belongs_to :user > acts_as_voteable > acts_as_commentable > attr_accessible :url, :title, :description, :vote_count > validates_presence_of :url, :title, :description > > ... > end > > > 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) > > content.vote_count +=1*factor > content.save! > ... > ... > end > > 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? > > thank you, > Jp > > -- João Miguel Pereira http://jpereira.eu LinkedIn: http://www.linkedin.com/in/joaomiguelpereira joaomiguel.pere...@gmail.com (351) 96 275 68 58 -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.