rgreen
1
I have the following code separated in 2 files.
module UsefulFeatures
def class_name
self.class.to_s
end
end
require UsefulFeatures
class Person
include UsefulFeatures
end
x = Person.new
puts x.class_name
Every time I try to run this I get the following error:
Test2.rb:1:in `’: uninitialized constant UsefulFeatures
(NameError)
What am I doing wrong?
rgreen
2
Rong wrote:
Every time I try to run this I get the following error:
Test2.rb:1:in `’: uninitialized constant UsefulFeatures
(NameError)
What am I doing wrong?
require’s argument is a file name
require ‘useful_features’
rgreen
4
Hi,
Am Dienstag, 08. Sep 2009, 15:45:28 +0900 schrieb Rong:
Nevermind. I found it.
Sorry, this information is not very helpful. Next time please post
the solution in case somebody googles for it.
Bertram
rgreen
5
Sorry, this information is not very helpful. Next time please post
the solution in case somebody googles for it.
But the solution is quite easy - he did not require the file properly,
else the constant would be known.