Created
December 8, 2011 19:03
-
-
Save levinotik/1448076 to your computer and use it in GitHub Desktop.
user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
validate :fb_id, :uniqueness => true, :presence => true | |
has_many :ratings | |
serialize :followed_users, Array | |
def initialize(params={}) | |
super(params) | |
self.score=0 | |
self.followed_users=[] | |
end | |
def self.generate_local_leaderboard | |
puts "not generating local leaderboard" | |
end | |
def update_average_rating | |
new_rating=0 | |
self.ratings.all.each do |rating| | |
new_rating += rating | |
end | |
new_rating = new_rating / self.ratings.count | |
self.average_rating=new_rating | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment