rails-timeago icon indicating copy to clipboard operation
rails-timeago copied to clipboard

Should enable future date by default

Open DannyBen opened this issue 9 years ago • 1 comments

This gem is doing a great job at simplifying live timestamp in rails.

I believe it should enable support for future dates by default, or at least provide an easy way (initializer option) to do so.

Even after following the discussion in issue #7 , I was unable to make it work without the need to add extra options to future dates.

I have added this to my application head:

<script>jQuery.timeago.settings.allowFuture = true;</script>

I have tested that future date works with this:

<%= timeago_tag 1.hours.from_now, force: true %>

But, what I really want is for this to work:

<%= timeago_tag Time.now %>
<%= timeago_tag 1.hours.from_now %>

Adding the limit option to an initializer, breaks one of the above (depends on whether the limit is in the past or future), and using the force option has the undesired side effect of ignoring the limit.

If there is a way around it, I think it should be mentioned somewhere clearly in the README, even if the suggestion to make it work out of the box is rejected.

EDIT

Also, I am not sure if its a bug or a feature - but most likely related. I was expecting the below two blocks to work the same. Pasted here as a repro case:

<h2>Doesnt work (first line is not converted)</h2>
<br><%= timeago_tag Time.now,         limit: 3.days.from_now %>
<br><%= timeago_tag 1.hours.from_now, limit: 3.days.from_now %>

<h2>Works</h2>
<br><%= timeago_tag Time.now,         force: true %>
<br><%= timeago_tag 1.hours.from_now, force: true %>

DannyBen avatar Oct 05 '15 11:10 DannyBen

Thanks for bringing this issue to light - we had wrapped everything with a limit and subsequently I couldn't figure out why allowFuture wasn't working as a setting. This definitely seems like a bug.

I think it would also be intuitive to enabled allowFuture by default, or otherwise ensure limit does not override this functionality.

Thanks for the great plugin!

watbe avatar Jun 19 '16 23:06 watbe