如何在Rails 3之外使用ActiveSupport核心扩展

52

我在开发一个gem时遇到使用ActiveSupport核心扩展的问题。

在AS 2.3.8上它可以工作,但是当我想将其移植到3b4时,这些扩展停止工作并且我的测试结果中充满了这样的行:

undefined method `blank?' for "something":String

我已经通过以下方式包含它

gem "activesupport"

紧跟着

require "active_support"

还需要调用其他内容来包含这些扩展吗?

1个回答

91

在Rails 3中,ActiveSupport更加独立了。

现在你可以使用require 'active_support/all'获取所有的active_support功能。

但是如果你只想要blank?方法,你可以尝试:

require 'active_support/core_ext/string'

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接