adds User#age

This commit is contained in:
Juanjo Bazán
2017-01-25 14:17:49 +01:00
parent 8d8d822323
commit 0b2454fb97
2 changed files with 15 additions and 0 deletions

View File

@@ -246,6 +246,14 @@ class User < ActiveRecord::Base
"#{name} (#{email})"
end
def age
if date_of_birth.blank?
nil
else
((Date.today - date_of_birth.to_date).to_i / 365.25).to_i
end
end
def save_requiring_finish_signup
begin
self.registering_with_oauth = true