Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的 Padrino 应用程序中,我试图从现在开始使用 10 年的时间
10.year.from_now
我越来越:
NoMethodError: 10:Fixnum 的未定义方法“年份”
知道为什么吗?!
默认情况下 ActiveSupport 没有完全加载,因为与 Rails 不同,Padrino 的目标是小而快。
如果您使用 ActiveRecord,则会加载全套 ActiveSupport,否则您需要(即在 boot.rb 中)您的依赖项。在你的情况下:
require 'active_support/core_ext' require 'active_support/duration'
我的建议是在真正需要时加载完整的 active_support 集。