如何解决activesupport 3.0.0与2.x相比的行为差异?

时间:2021-11-17 19:42:27

I am using Hash#to_xml in my Sinatra application. It did work till I moved to actviesupport 3.0.0

我在我的Sinatra应用程序中使用Hash#to_xml。它确实有效,直到我转移到actviesupport 3.0.0

Is there a difference in usage of activesupport in 3.0.0?

3.0.0中activesupport的使用有区别吗?

For example this works fine

例如,这很好

gem 'activesupport', '2.3.5'
require 'active_support'
{}.to_xml 

and

gem 'activesupport', '3.0.0'
require 'active_support'
{}.to_xml 

generates: NoMethodError: undefined method `to_xml' for {}:Hash

generate:NoMethodError:{}的未定义方法`to_xml':哈希

1 个解决方案

#1


9  

ActiveSupport no longer loads all its components when you require it. This allows you to cherry-pick the functionality that you want.

ActiveSupport在您需要时不再加载其所有组件。这使您可以选择所需的功能。

require "active_support/core_ext/hash/conversions"
{}.to_xml

Or if you really want all of ActiveSupport:

或者如果你真的想要所有的ActiveSupport:

require "active_support/all"

#1


9  

ActiveSupport no longer loads all its components when you require it. This allows you to cherry-pick the functionality that you want.

ActiveSupport在您需要时不再加载其所有组件。这使您可以选择所需的功能。

require "active_support/core_ext/hash/conversions"
{}.to_xml

Or if you really want all of ActiveSupport:

或者如果你真的想要所有的ActiveSupport:

require "active_support/all"