You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pgfqe6ch8/app/models/attendance.rb

16 lines
428 B

class Attendance < ActiveRecord::Base
attr_accessible :score, :user_id
default_scope :order => 'created_at desc'
include ApplicationHelper
# 超过1天即没有连续的签到则又从10个金币开始累加
def next_score
if time_between_days(Time.now, self.created_at) > 1
50
else
score = self.score.to_i < 50 ? 50 : self.score.to_i
(score + 10) < 100 ? score + 10 : 100
end
end
end