app/helpers/application_helper.rb
def time_ago_with_tooltip(time, placement: 'top', html_class: 'time_ago', skip_js: false)
    element = content_tag :time, time.to_s,
      class: "#{html_class} js-timeago #{"js-timeago-pending" unless skip_js}",
      datetime: time.to_time.getutc.iso8601,
      title: time.to_time.in_time_zone.to_s(:medium),
      data: { toggle: 'tooltip', placement: placement, container: 'body' }

    unless skip_js
      element << javascript_tag(
        "$('.js-timeago-pending').removeClass('js-timeago-pending').timeago()"
      )
    end

    element
  end
# Render a `time` element with Javascript-based relative date and tooltip
#
# time       - Time object
# placement  - Tooltip placement String (default: "top")
# html_class - Custom class for `time` element (default: "time_ago")
# skip_js    - When true, exclude the `script` tag (default: false)
#
# By default also includes a `script` element with Javascript necessary to
# initialize the `timeago` jQuery extension. If this method is called many
# times, for example rendering hundreds of commits, it's advisable to disable
# this behavior using the `skip_js` argument and re-initializing `timeago`
# manually once all of the elements have been rendered.
#
# A `js-timeago` class is always added to the element, even when a custom
# `html_class` argument is provided.
#
# Returns an HTML-safe String


By default also includes a `script` element with Javascript necessary to
initialize the `timeago` jQuery extension. If this method is called many
times, for example rendering hundreds of commits, it's advisable to disable
this behavior using the `skip_js` argument and re-initializing `timeago`
manually once all of the elements have been rendered.

A `js-timeago` class is always added to the element, even when a custom
`html_class` argument is provided.

Returns an HTML-safe String
By default also includes a ` script ` element with Javascript necessary to initialize the ` timeago ` jQuery extension . If this method is called many times for example rendering hundreds of commits it ' s advisable to disable this behavior using the ` skip_js ` argument and re - initializing ` timeago ` manually once all of the elements have been rendered . A ` js - timeago ` class is always added to the element even when a custom ` html_class ` argument is provided . Returns an HTML - safe String
def time_ago_with_tooltip(time, placement: 'top', html_class: 'time_ago', skip_js: false)
    element = content_tag :time, time.to_s,
      class: "#{html_class} js-timeago #{"js-timeago-pending" unless skip_js}",
      datetime: time.to_time.getutc.iso8601,
      title: time.to_time.in_time_zone.to_s(:medium),
      data: { toggle: 'tooltip', placement: placement, container: 'body' }
    unless skip_js
      element << javascript_tag(
        "$('.js-timeago-pending').removeClass('js-timeago-pending').timeago()"
      )
    end
    element
  end
def time_ago_with_tooltip ( time , placement : 'top' , html_class : 'time_ago' , skip_js : false ) element = content_tag :time , time . to_s , class : "#{html_class} js-timeago #{"js-timeago-pending" unless skip_js}" , datetime : time . to_time . getutc . iso8601 , title : time . to_time . in_time_zone . to_s ( :medium ) , data : { toggle : 'tooltip' , placement : placement , container : 'body' } unless skip_js element << javascript_tag ( "$('.js-timeago-pending').removeClass('js-timeago-pending').timeago()" ) end element end
Render a `time` element with Javascript-based relative date and tooltip
time       - Time object
placement  - Tooltip placement String (default: "top")
html_class - Custom class for `time` element (default: "time_ago")
skip_js    - When true, exclude the `script` tag (default: false)
Render a ` time ` element with Javascript - based relative date and tooltip time - Time object placement - Tooltip placement String ( default : " top " ) html_class - Custom class for ` time ` element ( default : " time_ago " ) skip_js - When true exclude the ` script ` tag ( default : false )
time
placement
html_class
skip_js