Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix difference in behavior of activesupport 3.0.0 compare to 2.x?

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

Is there a difference in usage of activesupport in 3.0.0?

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

like image 237
dimus Avatar asked Sep 04 '10 15:09

dimus


1 Answers

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

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

Or if you really want all of ActiveSupport:

require "active_support/all"
like image 54
molf Avatar answered Sep 22 '22 12:09

molf