# Including core class extensions from gems

**URL:** <https://www.ruby-forum.com/t/including-core-class-extensions-from-gems/81162>\
**Category:** Ruby\
**Created:** [January 5, 2007, 12:22pm UTC](https://www.ruby-forum.com/t/including-core-class-extensions-from-gems/81162 "2007-01-05T12:22:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sbraford](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@sbraford](https://www.ruby-forum.com/u/sbraford)\
**Post date:** [January 5, 2007, 12:22pm UTC](https://www.ruby-forum.com/t/including-core-class-extensions-from-gems/81162/1 "2007-01-05T12:22:36Z")

</div>

Hey all,

This question could just as easily be a good fit for the RoR list, but I  
figured it’s really more of a Ruby question, pertaining to a  
Rails-specific gem in this case.

What I’m trying to do… is leverage Rails’ activesupport gem.  
Specifically, the new Hash.from\_xml method (and all of its related  
dependencies).

> gem list | grep activesupport  
> activesupport (1.3.1, 1.2.5)

Check.

This is where I’m a little befuddled as to how to do this the Ruby  
way…

A simple test I’ve worked up to demonstrate whether or not this is  
working (hash\_from\_xml\_test.rb):

require ‘rubygems’  
require\_gem ‘activesupport’, ‘\>= 1.3.1’  
require ‘active\_support’  
require ‘active\_support/core\_ext’

class HashFromXmlTest \< Test::Unit::TestCase  
def test\_hash\_from\_xml  
h = Hash.from\_xml(‘bar’)  
assert h.is\_a?(Hash)  
end  
end

Running this gives a “NoMethodError: undefined method `from\_xml’ for  
Hash:Class”.

Any ideas?

Cheers,

- Shanti  
[http://onwebapps.com/](http://onwebapps.com/)

---

<div class="post-metadata">

**Author:** ![sbraford](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@sbraford](https://www.ruby-forum.com/u/sbraford)\
**Post date:** [January 6, 2007, 7:30pm UTC](https://www.ruby-forum.com/t/including-core-class-extensions-from-gems/81162/2 "2007-01-06T19:30:30Z")

</div>

On Jan 5, 2007, at 03:22, Shanti B. wrote:

> activesupport (1.3.1, 1.2.5)  
> require\_gem ‘activesupport’, ‘\>= 1.3.1’  
> You don’t need this line at all. Rubygems is smart and knows which  
> gem to load.

By the way, ‘require\_gem’ is deprecated, use ‘gem’

> Running this gives a “NoMethodError: undefined method `from\_xml’ for  
> Hash:Class”.

You probably have to load some other file. I’m sure grep will find  
it. If not, try the Rails list.

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)

I LIT YOUR GEM ON FIRE!
