私は別のファイルのクラスを使用しようとしています。別のファイルのクラスをどのように使用しますか?
something.rb
class Something
def initialize
end
def getText
'Some example text'
end
end
another.rb
class Another
end
somethingVar = Something.new
puts somethingVar.getText
これは私にエラー私が間違っているのは何
/usr/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /home/chris/RubymineProjects/untitled1/another.rb
/home/chris/RubymineProjects/untitled1/another.rb:4:in `<top (required)>': uninitialized constant Something (NameError)
from -e:1:in `load'
from -e:1:in `<main>'
を与えますか?
これはレールプロジェクトですか?そうでない場合は、定義を含むファイルを使用する前にそれを要求する必要があります。 – BroiSatse
@Chris、質問が答えられたと思ったら、その答えを受け入れたものとしてマークすることは良い考えです。 –