I have this function in my User model that calculates the User ages
def get_age
now = Time.now.utc.to_date
now.year - dob.year - ((now.month > dob.month || (now.month == dob.month && now.day >= dob.day)) ? 0 : 1)
end
I want a rails statement that yields a query against the users using this function and returns their age numbers. Then the ages are grouped in labels such as [below 10, between 10-20, etc]
something like:
<%= pie_chart User.group("get_age"), {library: {title: "User's Age"}} %>
where get_age is the function written in users model. Note: even when I define the function as self.get_age still it is not working