如何在Rails之外使用Rails 3的ActiveSupport核心扩展 [英] How to use Rails 3's ActiveSupport core extensions outside Rails

查看:64
本文介绍了如何在Rails之外使用Rails 3的ActiveSupport核心扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我正在开发的gem上使用ActiveSupport的核心扩展时遇到问题.

I'm having a problem using ActiveSupport's core extensions on a gem I am developing.

我已将其与AS 2.3.8一起使用,但是当我想将其移植到3b4时,扩展停止工作,并且我的测试结果充满了以下行:

I had it working with AS 2.3.8, but as soon as I wanted to port it to 3b4, the extensions stopped working and my test results are filled with lines such as:

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

我已经通过

gem "activesupport"

之后

require "active_support"

要添加这些扩展名,我还需要打电话吗?

Is there anything else I need to call to include those extensions?

推荐答案

ActiveSupport在Rails 3中现在更加独立.

ActiveSupport is more separate now in Rails 3.

如果需要全部active_support的东西,则可以立即require 'active_support/all'.

If you want the all active_support thing, you can require 'active_support/all' now.

但是,如果您只想使用blank?方法,则可以尝试

But if you want only the blank? method, you can try

require 'active_support/core_ext/string'

这篇关于如何在Rails之外使用Rails 3的ActiveSupport核心扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆