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

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -