I asked about this a few days ago and got no replies, so I’m asking
I have a file called string_extensions.rb. In it, I extend the String
to include some extra functionality. I put this file into the lib/
of my app.
But the changes made to String don’t take effect. The program acts as
the files aren’t being included.
I’ve stopped and restarted the server. No go. I tried including
Is there something I’m missing? Seems like it should just work.
Wow Ed. That’s a whole lot of work to include a file. Why not simply…
require “string_extensions” is sufficient
What Alan suggested works fine, I just think it’s odd… why have those
directories… or maybe they’re NOT included by default, but simply provided
by default… as placeholders… Hmm…
lib is part of the load path, meaning that if you do require
“file_name” then it’ll search in the lib dir for the filename. It
exists so that you can put stuff in there and just require it into
your files without having to do any of that RAILS_ROOT crap. Just
like any Ruby app though, the file’s contents are loaded into memory
until you require it.