title: How to use a RubyGems class in a Rails app
body: <p>I need to stream a TAR file using data from the database in a Rails app. 
  I know that RubyGems has the <code>TarWriter</code> module that suits my use case perfectly.</p>
  
  <p>The question is, how can I include the module in my Rails app?
  I tried to require rubygems/package as follows:</p>
  
  <pre><code>require 'zlib'
  require 'rubygems/package'
  
  tar = StringIO.new
  
  Gem::Package::TarWriter.new(tar) do |writer|
      writer.add_file("a_file.txt", 0644) do |f| 
          (1..1000).each do |i| 
              f.write("some text\n")
          end
      end
      writer.add_file("another_file.txt", 0644) do |f| 
          f.write("some more text\n")
      end
  end
  tar.seek(0)
  
  gz = Zlib::GzipWriter.new(File.new('this_is_a_tar_gz.tar.gz', 'wb'))
  gz.write(tar.read)
  tar.close
  gz.close
  </code></pre>
  
  <p>The <code>require</code> failed on the controller. I tried to adding <code>gem 'rubygems/package'</code> on my <code>Gemfile</code> but it didn't work.</p>
  
  <p>It's a noob question, how can I use RubyGems modules from a Rails app?</p>