0

in my age.html.erb

<%= f.label :date_of_birth%>
<%= f.date_field :date_of_birth,:order => [:day, :month, :year]%>

It shows only user birthyear data (like - 2000),
But I want to show only user total age like this (age-17).

Ajay Barot
  • 1,681
  • 1
  • 21
  • 37
adarsh
  • 306
  • 5
  • 16
  • It seems you've missed some code while posting the question, please fix it – nattfodd Feb 16 '18 at 10:43
  • 1
    create one method to calculate age `def age(dob) 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` Source https://stackoverflow.com/a/2357790 – Vishal Feb 16 '18 at 10:52

0 Answers0