Trying to require active_support in gem

I have a ruby โ€‹โ€‹stone, and I want to use the Hash.from_xml method in the stone, which is included in the rails active_support module. I have the code below in my gemspec:

gem.add_dependency 'active_support', '~> 3.0.0' 

However, when I collect and install the pearl locally, run irb, require a gem, I donโ€™t see which methods from active support are included?

Any suggestions on what I'm doing wrong or how to debug? Thanks!

+6
source share
1 answer

You need require methods that you need from ActiveSupport; they are not added by default.

As Eugene mentions in a comment, the way to do this is require "active_support/all" if you need everything, or if you want only Hash extensions to use require 'active_support/core_ext/hash' . Note that this usually does not happen in gemspec, but rather in any file that your stone uses to configure.

It might even be better to require required active support files in the actual files that need them, but this is a matter of taste.

+8
source

Source: https://habr.com/ru/post/953601/


All Articles