Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Jin He
Jin He
8,123 Points

How to use require to load a external gem in a normal ruby file

Suppose I have create a normal ruby file hello.rb, I want to require activerecord in my file, and use require 'activerecord', but this doesn't work, /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- activerecord (LoadError)

how am I gonna fix that ?

After some Googling, the only possible answer I could come up with is that Ruby is looking in the wrong place for gems, possibly because you're using a newer version. I'm not even remotely sure, sadly.

Maybe Jason Seifer will come along and know the answer, but for now I'll keep looking :)

Good Luck!

1 Answer

Jason Seifer
Jason Seifer
Treehouse Guest Teacher

Hi Jin He! I'm going to assume you have activerecord installed as a gem. In that case, you would do the following:

gem 'activerecord'
require 'active_record'

There are some more steps involved with getting active record itself to work but those are the basic steps to take for using a gem.