Categories
ruby

require file from same directory in ruby

Requiring a file sitting in the same directory wouldn’t work with this

require 'something'

Seems like Ruby 1.9 remove current directory from load path as I read from Stackoverflow

To make it work you could

require './something'

or use require_relative,

require_relative 'something'

The thing is,

load 'something.rb'

still work. So does that mean load and require have different load path?

By kahfei

A system admin by day while secretly trying to transform myself to a coding designer or a designing coder at night.

Leave a Reply

Your email address will not be published. Required fields are marked *