Sorry Im new to rails. I just found a way to calculate the age in a model from here : Get person's age in Ruby
The function is this :
def age
now = Time.now.utc
now.year - birthday.year - (birthday.to_time.change(:year => now.year) > now ? 1 : 0)
end
Can some one please explain whats happening in the third line? I can't understand this :
(birthday.to_time.change(:year => now.year) > now ? 1 : 0)