html - Rails Show Age in View based Born Date -


i have problem show age in view rails

i think solve:

 show.html.slim         `=@people.date_born - date.today / 365,25`       `end`   

what need do?

it's order of operations thing, syntax displayed funny. ignoring unnecessary quotes:

= ((date.today - @person.date_born) / 365).to_i 

first, since today greater date date of birth, want first avoid negative number. need wrap in parens subtraction first, , divide, , legibility, change integer.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -