-1

How can I navigate back one or multiple directories in Ruby?

For example:

users/luigi/test/folder/file.rb

If I'm in the folder directory and want my file.rb script to load a file from within the test directory, how can I do that?

Something like:

require /../required_file.rb

1
  • 1
    .. is parent directory Commented Dec 9, 2013 at 15:09

2 Answers 2

3

You can use require_relative

require_relative "../test/file.rb" 
Sign up to request clarification or add additional context in comments.

Comments

0
require_relative "../requred_file.rb" 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.