gpt4 book ai didi

ruby-on-rails - 如何在 rails 之外使用 active_support 提供的方法

转载 作者:数据小太阳 更新时间:2023-10-29 07:46:23 24 4
gpt4 key购买 nike

如何使用 ActiveSupport 模块中定义的方法?

例如我想使用camelize 方法。

我试过这段代码,但它没有用 undefined method 错误。

require 'active_support'
"foo_bar".camelize

最佳答案

您可以只需要提供 camelize 的部分,而不是 所有 Active Support:

require 'active_support/core_ext/string'
"camel_this".camelize => "CamelThis"

关于ruby-on-rails - 如何在 rails 之外使用 active_support 提供的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23463821/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com