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
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.