uses Date#age_in_years when calculating ages

This commit is contained in:
kikito
2017-02-03 12:56:40 +01:00
parent 3535cfc0d6
commit 95f80651b1
4 changed files with 4 additions and 11 deletions

View File

@@ -247,14 +247,7 @@ class User < ActiveRecord::Base
end
def age
if date_of_birth.blank?
nil
else
now = Time.now.utc.to_date
now.year - date_of_birth.year - (
(now.month > date_of_birth.month || (now.month == date_of_birth.month && now.day >= date_of_birth.day)
) ? 0 : 1)
end
date_of_birth.try(:age_in_years)
end
def save_requiring_finish_signup