相关疑难解决方法(0)

为什么日期帮助程序在Rails控制台中不起作用?

我在记录上有一个datetime属性:

 1.9.3p194 :024> f.last_contact
 => Thu, 11 Aug 2011 00:00:00 UTC +00:00 
Run Code Online (Sandbox Code Playgroud)

但是当我time_ago_in_words在控制台上尝试时,它不起作用:

> time_ago_in_words(f.last_contact)
NoMethodError: undefined method `time_ago_in_words' for main:Object
Run Code Online (Sandbox Code Playgroud)

我也尝试过distance_of_time_in_words哪些文档应该使用Time,Date和DateTime对象.

> 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
Run Code Online (Sandbox Code Playgroud)

这是什么原因?Rails控制台不应该为所有Rails方法加载所有必要的库和依赖项吗?

ruby-on-rails ruby-on-rails-3

25
推荐指数
2
解决办法
7751
查看次数

标签 统计

ruby-on-rails ×1

ruby-on-rails-3 ×1