如果用户追溯性地创建了质询,那么他已accomplished
before_save
如何days_left_challenged == 0
?
before_save :days_left_challenged_sets_deadline
def days_left_challenged_sets_deadline
if self.days_left_challenged == 0
self.accomplished = true
end
end
def days_left_challenged
self.days_challenged - ((date_started.to_date)..Date.yesterday).count do |date|
committed_wdays.include? date.wday
end + self.missed_days
end
即使用户创建了具有accomplished
的质询,立即使用此代码nil
仍为days_left_challenged == 0
。
答案 0 :(得分:0)
它必须是days_left_challenged <= 0
因为我没有意识到它并没有停留在0. Rookie的错误。