1

我最近将一些代码从我的seeds.rb 移到了我的控制器中。在 seed.rb 中,代码有效。

# for each day create the time slots.
start_time = Time.beginning_of_day
end_time = start_time.end_of_day

Time.beginning_of_day给了我一个 NoMethodError。我很迷惑。基于 Rails 指南,所有 ActiveSupport 都加载到 Rails 应用程序中。你能告诉我为什么它在我的控制器中不起作用吗?

4

1 回答 1

3

您应该为该类的实例调用该方法。

Time.now.beginning_of_day
于 2013-04-30T04:38:48.420 回答