I know this looks trivial but let say that in Ruby on Rails I have
document.expire_in = 7.days
how can I print human readable version of the expiry mesages ?
"Document will expire in #{document.expire_in}"
=> Document will expire in 7 days
maybe something that works with I18n.t
or I18n.l
the only way this works is
7.days.inspect => "7 days"
is this the only way ??
I'm looking at ActiveSupport::Duration and don't see an answer
thx
This doesn't answer your specific question but it seems to me that you would be better off setting the datetime that it expires and then leverage distance_of_time_in_words.
If you're always going to simply say 7 days, then why not just write that as a hard-coded string?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With