How can I alter the query below to only select records created within the last 7 days?
self.favorites.count
This function is located in my User model.
def calculate_user_score
unless self.new_record?
self.score = (self.links.count * 5) + (self.favorites.count * 0.5)
end
end
You can add a
where-condition like this:And for your
calculate_user_scoremethod, you probably want to do that forlinksas well: