Displaying 1 result from an estimated 1 matches for "age_year_month".
2006 Jan 25
0
Another crack at age calculations
I cobbled this together based on a few previous posts and some tinkering,
nothing fancy (my first bit of Ruby infact) but it seams to work for my
purposes.
My questions is actually why can I call <%= h(child.age(child.dob)) %> in a view
but not <%= h(child.age_year_month(child.dob)) %>? Both work fine in the
console.
Thanks for any insight,
Hugh
child.rb
class Child < Person
end
person.rb
class Person < ActiveRecord::Base
def age(dob)
unless dob.nil?
years = Date.today.year - dob.year
months = years * 12
months = months + (Dat...