ruby-on-railsrubyruby-on-rails-3ruby-on-rails-4timeago

Stopping counter with rails-timeago


I am timing a task from the date with the gem rails-timeago. The count appears in the view and I use the following code for this:

<% = Timeago_tag task.data,: nojs => true,: limit => 10.days.ago%>

I want to develop a button that when clicking the time count stops.

Can anyone help?

Thank you!


Solution

  • This gem is not what you need and have another purpose. It's just a helper, that using your timestamps (created_at/updated_at) and draw up it's appearance.

    You can add new field (timestamp) into your database completed_at and save there the time of task that was completed. You can also add started_at and use it as timestamp for time when task was started or simply use created_at. You still can use time_ago gem to count elapsed time or output it in a pretty appearance.