Why do date helpers not work in Rails console?

I have a datetime attribute on a record:

 1.9.3p194 :024> f.last_contact
 => Thu, 11 Aug 2011 00:00:00 UTC +00:00 

But when I try time_ago_in_words at the console, it doesn't work:

> time_ago_in_words(f.last_contact)
NoMethodError: undefined method `time_ago_in_words' for main:Object

I also tried distance_of_time_in_words which the docs say should work with Time, Date & DateTime objects.

> to_time = Time.now
 => 2012-09-08 12:22:16 -0500 
> distance_of_time_in_words(f.last_contact, to_time)
NoMethodError: undefined method `distance_of_time_in_words' for main:Object

What is the cause of this? Shouldn't Rails Console load all the necessary libraries and dependencies for all of Rails methods to work?


You can use all helpers (built-in and your own) through helper object

=> "about 1 hour"

Or import required helpers

include ActionView::Helpers::DateHelper
=> "about 1 hour" 

Need Your Help

Automapper Member mapping on codition SeemsConvoluted

c# automapper

I'm trying to find the correct way to implement this.

Pre-focus input box before fadeIn

javascript jquery html textinput

I have two input fields. The second input starts focused. I then want to fadeOut both inputs, having the second input staying focused until the end. Finally, I want to fadeIn both inputs and end up...