Re: How can I update another model from current model?

2009-11-04 Thread djo26
> and of course increment the total_votes column. > > So the pseudocode for Post::addVote(score) is >     if post exists >         find average_vote and total_votes >         set average_vote to ((average_vote * total_votes) + score) / > (total_votes + 1) >         set total

How can I update another model from current model?

2009-11-03 Thread djo26
Hi everyone, I have Posts that have Votes, and the Vote has a percentage. Every time a new Vote is added I want to calculate the average percentage of all Votes of that particular Post and update the Post average percentage. Besides a custom query I have no idea how to do this in my model. Anyone