El jueves, 11 de febrero de 2016 6:52:04 (CET) Gloufy escribió: > Hello, > > Does somebody have manage to search with age ? > In my database i have date of birth and i want to manage to find all the > personne who have 35 years old. > And all the people have 20-35 years old > Do you know how to do that ? > Thank you > Gloufy
You should calculate the range of dates of birth for people who are 35 years old. Probably: age = 35 end_range = Date.today -35.years range = end_range.prev_year.tomorrow..end_range Person.where(birthday: range) For age range: start_age = 20 end_age = 35 start_range = (Date.today - end_age).prev_year.tomorrow end_range = Date.today - start_age Person.where(birthday: start_range..end_range) -- You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails Gem" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/activescaffold. For more options, visit https://groups.google.com/d/optout.
