Skip to content

Instantly share code, notes, and snippets.

Created August 16, 2016 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/ad9aec0685872b4b4e5779cdaa25f007 to your computer and use it in GitHub Desktop.
Save anonymous/ad9aec0685872b4b4e5779cdaa25f007 to your computer and use it in GitHub Desktop.
class Person
def self.where_age(age)
min = Date.current - age.to_i.years - 1.year
max = Date.current - age.to_i.years + 1.day
where(date_of_birth: min..max)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment