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

查看:10
本文介绍了如何在 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?

推荐答案

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

ActiveSupport is more separate now in Rails 3.

如果你想要 all 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天全站免登陆