Today I had to calculate an age in Rails and I wanted to share the process and final outcome and see if anyone had a nicer way.
My first attempt was pretty naive;
Time.zone.now.year - date_of_birth.year
Recently I saw a post that explained a gotcha around Rails with the use of callbacks when checking for changed fields. This gotcha does exist but there is an easy solution.
What is the difference is between count and length in Rails and is there much difference? Knowing the differences could lead to improved performance.