Basic help about "require"

Hi All,

I have 2 folders.

Folder1 --> folder name “child” --> it contains child1.rb

Folder1 --> folder name “parent” --> it contains parent1.rb

MY NEED"

parent.rb

require ‘…/child/child1’

It is giving error.

I want to require child1.rb in parent1.rb.

Please help to solve this issue.

Thanks

Hi All,

I got a solution but i think its not a proper one.

Solution

Dir[File.join(File.dirname(FILE), ‘child’, “*.rb”)].each do |file|
require file
end

Any other solutions ?

2009/6/14 Raveendran P. [email protected]

Any other solutions ?

Posted via http://www.ruby-forum.com/.

At windows platform
you need a complete path of the file

Hi,
In parent1.rb, try this:

require File.join(File.dirname(FILE), ‘…’, ‘child’, ‘child1’)

Cheers,
Jits

2009/6/14 å¼ æ˜Šæ˜± [email protected]