E
E
epolyak2015-12-14 18:54:50
ruby
epolyak, 2015-12-14 18:54:50

RUBY - connect class?

I started learning Ruby - I mastered the base a little, tutorials.
I wrote a script - it works. I added a file with a class next to the script, how to use the class in my script?
Since when I try to use it I get an error:
`require': cannot load such file -- topic
The code itself looks like this:

require 'topic'
.....
topic = Topic.new
.....

The topic.rb file is next to the executable file. I run the command:
ruby app.rb

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Demidenko, 2015-12-14
@epolyak

Use require_relative
require_relative 'topic'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question