So i want item to display to remaining on Items after 7 days the item will be deleted. ive tried
<%= distance_of_time_in_words(item.created_at, item.created_at + 7.days) %>
but all i get is "7 Days" on all items. Can anyone simply how this helper method works ?
Lets looks at the documentation to see what
distance_of_time_in_wordsdoes:So it reports the time difference of the first argument and the second argument. Now, you're doing:
The difference between
item.created_atanditem.created_atplus seven days is always ... seven days ;-)I assume that this is something that will always be deleted after seven days? In that case, what you want, is the difference between the current date and the creation date plus seven days, which you can get with: