【发布时间】:2012-09-02 05:03:13
【问题描述】:
我在记录上有一个日期时间属性:
1.9.3p194 :024> f.last_contact
=> Thu, 11 Aug 2011 00:00:00 UTC +00:00
但是当我在控制台尝试time_ago_in_words 时,它不起作用:
> time_ago_in_words(f.last_contact)
NoMethodError: undefined method `time_ago_in_words' for main:Object
我还尝试了distance_of_time_in_words,文档说它应该与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
这是什么原因? Rails 控制台不应该加载所有必要的库和依赖项以使所有 Rails 方法工作吗?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3