module ActionView::Helpers::DateHelper

def relative_time_in_words(from_time, options = {})

See also #time_ago_in_words

relative_time_in_words(10.seconds.ago, include_seconds: true) # => "less than 10 seconds ago"
relative_time_in_words(3.minutes.ago) # => "3 minutes ago"
relative_time_in_words(3.minutes.from_now) # => "in 3 minutes"

are forwarded to time_ago_in_words.
You can use the scope option to customize the translation scope. All other options
Like time_ago_in_words, but adds a prefix/suffix depending on whether the time is in the past or future.
def relative_time_in_words(from_time, options = {})
  now = Time.now
  time = distance_of_time_in_words(from_time, now, options.except(:scope))
  key = from_time > now ? :future : :past
  I18n.t(key, time: time, scope: options.fetch(:scope, :'datetime.relative'), locale: options[:locale])
end